#include "locmin.h"
#include <bits/stdc++.h>
const int MAXN = 500;

long long mat[MAXN + 2][MAXN + 2];
int dl[] = { 0, -1, 1, 0 };
int dc[] = { 1, 0, 0, -1 };

bool verif( int i, int j ) {
    int cnt = 0;
    for( int dir = 0; dir < 4; dir++ )
        if( mat[i + dl[dir]][j + dc[dir]] >= mat[i][j] )
            cnt++;
    return cnt == 4;
}

std::pair <int, int> find_locmin_point(int N, int M) {
    int i, j, n, m;
    n = N;
    m = M;
    i = 1;
    for( j = 1; j <= m; j++ ) {
        mat[i][j] = value( i, j );
        if( j >= 2 && verif( 1, j - 1 ) )
            return { 1, j - 1 };
    }
    return { 1, 1 };
}
