#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
long long value(int r, int c);
std::pair<int, int> find_locmin_point(int N, int M) {
    vector<vector<long long>> a(N + 1, vector<long long>(M + 1, 2e18));
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= M; ++j) a[i][j] = value(i, j);
    }
    vector<pair<int, int>> to = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= M; ++j) {
            bool flag = true;
            for (auto [a1, a2] : to) {
                int ti = i + a1, tj = j + a2;
                if (1 <= ti && ti <= N && 1 <= tj && tj <= M) {
                    if (a[ti][tj] <= a[i][j]) flag = false;
                }
            }
            if (flag) return std::pair<int, int>{i, j};
        }
    }
}
/*signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    auto [a1, a2] = find_locmin_point(3, 4);
    cout << a1 << ' '<< a2 << endl;
    return 0;
}*/
