#include "locmin.h"
#include <bits/stdc++.h>

long long inf = 1e18;
std::pair <int, int> find_locmin_point(int N, int M) {
    if(N == 1)
    {
        if(M == 1)return {1,1};
        int tl = 1;
        int tr = M;
        int rez = inf;
        while(tl <= tr)
        {
            int mid = tl+tr>>1;
            int left = inf;
            int right = inf;
            int v = value(1,mid);
            if(mid>1)left = value(1,mid-1);
            if(mid<M)right = value(1,mid+1);
            if(v < left && v < right)
            {
                rez = mid;
                break;
            }
            else if(v >= left)tr = mid-1;
            else tl = mid+1;
        }
        if(rez == inf)rez = tl+tr>>1;
        return {1,rez};
    }
}
