#include <bits/stdc++.h>

using namespace std;

long long value(int r, int c);

std::pair<int, int> find_locmin_point(int n, int m){
    pair<int,int> curr = {n/2+1,m/2+1};
    int val = value(n/2+1,m/2+1);
    while(true){
        pair<int,int> next = {-1,-1};
        int new_val=val;
        if(curr.first<n-1){
            int x = value(curr.first+1+1,curr.second+1);
            if(new_val > x){
                next = {curr.first+1,curr.second};
                new_val = x;
            }
        }
        if(curr.first>0){
            int x = value(curr.first-1+1,curr.second+1);
            if(new_val > x){
                next = {curr.first-1,curr.second};
                new_val = x;
            }
        }
        if(curr.second<m-1){
            int x = value(curr.first+1,curr.second+1+1);
            if(new_val > x){
                next = {curr.first,curr.second+1};
                new_val = x;
            }
        }
        if(curr.second>0){
            int x = value(curr.first+1,curr.second-1+1);
            if(new_val > x){
                next = {curr.first,curr.second-1};
                new_val = x;
            }
        }
        if(next.first == -1) return curr;

        curr = next;
        val = new_val;
    }
}

/*
static const int MAXN=500,MAXM=500;
static long long int tab[MAXN][MAXM];
static int n,m;
static void finish (string message) {
    cout << message << endl ;
    exit(0);
}

static int cnt=0;
long long int value (int row, int col) {
    row--; col--;
    if ((row<0)||(row>=n)||(col<0)||(col>=m)) finish("Invalid row or column number in question ("+to_string(row)+","+to_string(col)+")!");
    cnt++;
    if (cnt>n*m) finish("Too many questions!");
    return tab[row][col];
}
extern pair <int, int> find_locmin_point (int, int);

static int drow[]={ -1, -0, +0, +1 };
static int dcol[]={ -0, -1, +1, +0 };
static 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 () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m ;
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            cin >> tab[i][j] ;
        }
    }
    auto [r, c]=find_locmin_point(n,m);
    cout << "Answer cell: (" << r << "," << c << ")\n";
    cout << "Number of value calls: " << cnt << endl ;
    r--; c--;
    if ((r<0)||(r>=n)||(c<0)||(c>=m)) finish("Invalid row or column in answer!");
    if (check_saddle(r,c)==false) finish("Answer is not a local minimum point!");
    finish("Correctly found local minimum point.");
    return 0;
}
*/