#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cstdio>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <cstring>
#define endl '\n'

using namespace std;
typedef long long ll;

vector<ll> used[401 * 401 + 7];

ll block[401 * 401 + 7];

vector<ll>d[401 * 401 + 7];

ll vilna;

vector<pair<ll, ll>> ans;

ll obrob[401 * 401 + 7];

void dfs(ll v){
    obrob[v] = 1;
    
    for(auto i: d[v]){
        if(obrob[i] == 1)
            continue;
        
        ans.push_back({i, vilna});
        ans.push_back({v, i});
        
        vilna = v;
        
        dfs(i);
    }
    return;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n, m;
    cin >> n >> m;
    
    vector<ll>a(n * m);
    for(int i = 0; i < n * m; i++)
        cin >> a[i];
    
    vector<ll>block(n);
    
    ll last = 0;
    
    ll pos1 = -1, pos2 = -1;
    
    for(int i = 0; i < n; i++){
        vector<vector<ll>>used(m + 1);
        
        for(int j = last; j < last + m; j++)
            used[a[j]].push_back(j);
        
        for(int j = 1; j <= m; j++){
         
            
            if(used[j].size() > 0 && pos1 == -1)
                pos1 = used[j][0];
            else if(used[j].size() > 0 && pos2 == -1)
                pos2 = used[j][0];
        }
        
        
        last += m;
    }
    
    cout << 3 << endl;
    cout << pos1 + 1 << ' ' << n * m + 1 << endl;
    cout << pos2 + 1 << ' ' << pos1 + 1 << endl;
    cout << n * m + 1 << ' ' << pos2 + 1 << endl;
    
    return 0;
}
/*
 
 4 3
 1 1 3
 1 2 2
 3 1 3
 3 2 2
 
 */
 
 
