#include <bits/stdc++.h>
#include "locmin.h"
const int MAXN = 500;
long long mat[MAXN + 2][MAXN + 2];
int n, m;
long long get_val(int l, int c) {
  if(l < 1 || l > n || c < 1 || c > m)
    return 1e18 + 1;
  if(mat[l][c] == 0) {
    mat[l][c] = value(l, c);
  }
  return mat[l][c];
}
int dl[4] = {-1, 0, 1, 0};
int dc[4] = {0, 1, 0, -1};
bool local_max(int l, int c, int N, int M) {
  for( int dir = 0; dir < 4; dir++ ) {
    if(mat[l + dl[dir]][c + dc[dir]] != 0 && mat[l + dl[dir]][c + dc[dir]] < mat[l][c])
      return 0;
  }
  return 1;
}

std::pair<int, int> find_locmin_point(int N, int M) {
  n = N;
  m = M;
  int st = 0;
  int dr = m + 1;
  while(dr - st > 1) {
    int mij = (st + dr) / 2;
    if(get_val(1, mij - 1) < get_val(1, mij))
      dr = mij;
    else
      st = mij;
  }
  return {1, dr - 1};
}
/*
1 11
12 11 10 9 8 7 6 5 4 6 2
*/
