#include "locmin.h"
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
vector<ll> vec(501,-1);
const double phi=1.618;
ll ask(ll i){
    if(vec[i]==-1)vec[i]=value(1,i);
    return vec[i];
}
ll get(ll a, ll b){
    ll c=((phi)/(2*phi+1))*(b-a)+a;
    ll d=((1+phi)/(2*phi+1))*(b-a)+a;
    ask(a);ask(b);ask(c);ask(d);
    if(a==b-1){
        return min<pair<ll,ll>>({{vec[a],a},{vec[b],b},{vec[c],c},{vec[d],d}}).second;
    }
    if(a==b-2){
        return min<pair<ll,ll>>({{vec[a],a},{vec[b],b},{vec[c],c},{vec[d],d}}).second;
    }
    if(vec[c]>vec[a])return get(a,c);
    if(d>b)return get(d,b);
    if(c<d)return get(a,d);
    return get(c,b);
}
std::pair <int, int> find_locmin_point(int N, int M) {
    return {1,get(1,M)};
}
