#include <bits/stdc++.h>
using namespace std;

int k[405][405];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int n, m;
	cin>>n>>m;
    int a[n+1][m+1];
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            cin>>a[i][j];
            k[i][a[i][j]]++;
        }
    }
    vector<pair<int,int>> res;
    for(int j = 1; j <= n; j++)
    {
        if(k[n][j] == 0)
        {
            for(int i1 = 1; i1 < n; i1++)
            {
                if(k[i1][j] > 1)
                {
                    for(int j1 = 1; j1 <= n; j1++)
                    {
                        if(a[i1][j1] == j)
                        {
                            res.push_back({j1*i1, n*m+1});
                        }
                    }
                }
            }
        }
    }
    cout<<res.size()<<'\n';
    for(auto to: res)
    {
        cout<<to.first<<" "<<to.second<<'\n';
    }
}
