#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 10;
const int MAX = 510;
long long mem[MAX];
bool vis[MAX];
long long value(int r, int c);
pair<int, int> find_locmin_point(int N, int M){
	int l = 1, r = M;
	while(l < r - 1){
		//cout << l << ' ' << r << endl;
		int mid = (l + r) / 2;
		long long pred, curr, sled;
		if(mid - 1 > 0 && vis[mid - 1] == true){
			pred = mem[mid - 1];
		}else if(mid > 1){
			pred = value(1, mid - 1);
			mem[mid - 1] = pred;
			vis[mid - 1] = true;
		}else{
			pred = INF;
		}
		if(mid + 1 <= M && vis[mid + 1] == true){
			sled = mem[mid + 1];
		}else if(mid < M){
			sled = value(1, mid + 1);
			mem[mid + 1] = pred;
			vis[mid + 1] = true;
		}else{
			sled = INF;
		}
		if(vis[mid] == true){
				curr = mem[mid];
		}
		else {
				curr = value(1, mid);
				mem[mid] = curr;
				vis[mid] = true;
		}
		//cout << pred << ' ' << curr << ' ' << sled << endl;
		if(pred > curr && sled > curr){
			return make_pair(1, mid);
		}
		if(pred < curr){
			//cout << "small" << endl;
			r = mid;
			continue;
		}
		if(sled < curr){
			//cout << "big" << endl;
			l = mid;
			continue;
		}
		//cout << l << ' ' << r << endl;
	}
}
