#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll value(int r, int c);

namespace k1r1t0 {

const ll INF = (ll)(1e18) + 1;

int n, m;

map<array<int, 2>, ll> mp;
ll val(int r, int c) {
    if (r < 1 || c < 1 || r > n || c > m) return INF;
    if (mp.find({r, c}) != mp.end())
        return mp[{r, c}];
    mp[{r, c}] = value(r, c);
    return mp[{r, c}];
}

array<ll, 2> getmin(int c) {
    array<ll, 2> cur = {INF, INF};
    for (int i = 1; i <= n; i++)
        cur = min(cur, {val(i, c), i});
    return cur;
}

// < is false
// >= is true
bool sg(int k) {
    array<ll, 2> x = getmin(k);
    return x[0] >= val(x[1], k + 1);
}

pair<int, int> find_locmin_point(int N, int M) {
    n = N;
    m = M;
    int l = 0, r = M;
    int cnt = 0, val = M;
    while (val > 1) {
        val = (val + 1) / 2;
        cnt++;
    }
    if ((N + 1) * cnt + N >= 5010) {
        if (!sg(1)) return {getmin(1)[1], 1};
        l++;
    }
    while (r - l > 1) {
        int k = (l + r) / 2;
        if (sg(k)) l = k;
        else r = k;
    }
    array<int, 2> res = {getmin(r)[1], r};
    return {res[0], res[1]};
}

};

pair<int, int> find_locmin_point(int N, int M) {
    return k1r1t0::find_locmin_point(N, M);
}


























#ifdef LOCAL
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;
}


#endif
