#include "locmin.h"
#define ll long long
#define INF 1000000000000000001
using namespace std;
#include <bits/stdc++.h>
vector<vector<ll>> v, dir = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
std::pair <int, int> find_locmin_point(int N, int M) {
    v.assign(N + 2, vector<ll>(M + 2, INF));
    for (int i = 1; i <= N; i++){
        for (int j = 1; j <= M; j++){
            v[i][j] = value(i, j);
        }
    }
    for (int i = 1; i <= N; i++){
        for (int j = 1; j <= M; j++){
            int can = 1;
            for (auto el : dir){
                if (v[i + el[0]][j + el[1]] < v[i][j]) can = 0;
            }
            if (can) return {i, j};
        }
    }
    return {1, 1};
}
