#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
long long value(int r, int c);
std::pair <int, int> find_locmin_point(int N, int M){
    if(N == 1 && M == 1) return {1, 1};
    ll l = 2, r = M - 1;
    if(value(1, 1) < value(1, 2)) return {1, 1};
    if(value(1, M) < value(1, M - 1)) return {1, M};
    while(l != r){
        ll tm = (l + r) / 2;
        ll a = value(1, tm-1);
        ll b = value(1, tm);
        ll c = value(1, tm+1);
        if(b < a && b < c) return {1, tm};
        if(a > b && b > c)
            l = tm + 1;
        else r = tm;
    }
    return {1, l};
}