#include "locmin.h"
#include <bits/stdc++.h>
using namespace std;
pair<int, int> find_locmin_point(int N, int M) {
    vector<vector<long long>> v(N + 1, vector<long long>(M + 1));
    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++){
            bool fl = 1;
            fl &= (i == 1 || v[i - 1][j] > v[i][j]);
            fl &= (i == N || v[i + 1][j] > v[i][j]);
            fl &= (j == 1 || v[i][j - 1] > v[i][j]);
            fl &= (j == M || v[i][j + 1] > v[i][j]);
            if(fl){
                return {i, j};
            }
        }
    }
    return {-1, -1};
}
