#include "testlib.h"
#include<iostream>
#include<string>
#include<vector>
#include<set>
#define MAXN 500
#define MAXM 500
#define MAXNUM 1000000
using namespace std;
void error_message (const char message[]) {
    cerr << "Error - " << message << "\n";
    exit(0);
}
int tab[MAXN][MAXM],n,m;
int drow[]={ -1, -0, +0, +1 };
int dcol[]={ -0, -1, +1, +0 };
bool check_equal (int row, int col) {
    for (int i=0; i<4; i++) {
        int r=row+drow[i],c=col+dcol[i];
        if ((r<0)||(r>=n)||(c<0)||(c>=m)) continue;
        if (tab[r][c]==tab[row][col]) return true;
    }
    return false;
}
bool check_saddle (int row, int col) {
    for (int i=0; i<4; i++) {
        int r=row+drow[i],c=col+dcol[i];
        if ((r<0)||(r>=n)||(c<0)||(c>=m)) continue;
        if (tab[r][c]<=tab[row][col]) return false;
    }
    return true;
}
int main (int argc, char* argv[]) {
    if (argc==1) error_message("the test validator needs arguments!\n");
    FILE* fin;
    fin=fopen(argv[1],"r");
    if (fin==NULL) error_message("wrong test name!");
    fclose(fin);
    freopen(argv[1],"r",stdin);
    registerValidation(argc,argv);

    n=inf.readInt(1,MAXN,"N"); inf.readSpace();
    m=inf.readInt(1,MAXM,"M");
    inf.readEoln();
    int min1=MAXNUM+1,max1=0;
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            tab[i][j]=inf.readInt(1,MAXNUM,"aij");
            if (j!=m-1) inf.readSpace();
            min1=min(min1,tab[i][j]);
            max1=max(max1,tab[i][j]);
        }
        inf.readEoln();
    }
    inf.readEof();

    int cnt=0;
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            ensuref(check_equal(i,j)==false,"equal cells!");
            if (check_saddle(i,j)==true) {
                cout << i+1 << " " << j+1 << endl ;
                cnt++;
            }
        }
    }

    cout << n << " " << m << " " << cnt << "  " << min1 << " " << max1 << endl ;
    if (n==1) cout << "First subtask!\n";
    else cout << "Second subtask!\n";
    cout << "Test is OK!\n";
    return 0;
}
