#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int,int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define debug(x) cerr<<#x<<" is "<<x<<endl;
#define sz(x) (int)(x).size()
#define pb push_back
#define ipii pair<int,pii>
int ans=-1;
void check(int l,int h){
if(ans!=-1)return;
bool f=1;
if(l==h)return;
int m=(l+h)/2;
vi res=ask(m);
if(res[0]==0){
if(res[1]==0){
ans=m;
return;
}else if(f)check(m,h);
}else{
if(f)check(l,m);
if(res[1]>0&&f)check(m,h);
}
}
int find_best(int n) {
check(-1,n);
//for(int i=0;i<30000;i++)ask(0);
return ans;
}