#include<bits/stdc++.h>
#include "locmin.h"
using namespace std;
#define MAXN 505

long long matrix[MAXN][MAXN];

std::pair <int, int> find_locmin_point(int N, int M)
{
    if (N==1)
    {
        if (M==1) return {1,1};
        int l=1,r=M;matrix[1][0]=LLONG_MAX;matrix[1][M+1]=LLONG_MAX;
        while (l<=r)
        {
            int mid=(l+r)/2;
            if (matrix[1][mid]==0) matrix[1][mid]=value(1,mid);
            if (matrix[1][mid-1]==0) matrix[1][mid-1]=value(1,mid-1);
            if (matrix[1][mid+1]==0) matrix[1][mid+1]=value(1,mid+1);
            if (matrix[1][mid]<matrix[1][mid-1] and matrix[1][mid]<matrix[1][mid+1]) return {1,mid};
            if (matrix[1][mid-1]<matrix[1][mid+1]) r=mid-1;
            else l=mid+1;
        }
    }
}