#include "locmin.h"
#include <bits/stdc++.h>
using namespace std;
int val[505][505];
void qry(int x, int y)
{
    if(!val[x][y])
        val[x][y] = value(x,y);
}
pair<int,int> solve_n1(int M)
{
    if(M == 1)
        return {1,1};

    qry(1,1);
    qry(1,2);
    qry(1,M);
    qry(1,M-1);

    if(val[1][1] < val[1][2])
        return {1,1};
    if(val[1][M] < val[1][M-1])
        return {1,M};

    int st = 2, dr = M-1, ans = -1;
    while(st <= dr)
    {
        int mij = (st + dr) / 2;
        qry(1,mij);
        qry(1,mij-1);
        qry(1,mij+1);
        if(val[1][mij] < val[1][mij-1] && val[1][mij] < val[1][mij+1])
            return {1, mij};
        if(val[1][mij] > val[1][mij-1])
        {
            dr = mij - 1;
        }
        else
        {
            assert(val[1][mij] > val[1][mij+1]);
            st = mij + 1;
        }
    }
    assert(0);
}
pair<int, int> find_locmin_point(int N, int M)
{
    assert(N == 1);
    return solve_n1(M);
}
/*

1 5
3 1 4 2 5

3 4
5 3 5 6
10 6 4 10
2 9 8 2

 */