#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll value(int i, int j);

int get(int i, int m) {
    int l = 1, r = m;

    while (l < r) {
        int mid = (l + r) >> 1;

        ll x = value(i, mid), y = value(i, mid + 1);
        if (y < x) { l = mid + 1; continue; }
        else {
            if (mid == 1) return 1;
            ll z = value(i, mid - 1);
            if (z < x) r = mid - 1;
            else return mid;
        }
    }

    return l;
}

pair < int , int > find_locmin_point(int n, int m) {
    for (int i = 1; i <= n; i++) {
        int p = get(i, m);
        bool bad = 0;
        ll x = value(i, p);
        if (i > 1) if (value(i - 1, p) < x) bad = 1;
        if (i < n) if (value(i + 1, p) < x) bad = 1;
        if (!bad) return make_pair(i, p);
    }

    exit(1);
}
