#include using namespace std; typedef long long ll; int k; int q(int x, int y) { cout << x << " " << y << endl; cout.flush(); int res; cin >> res; return res; } ll sim(int x) { int a[2] = { 0, 0 }; a[k] = x; return q(a[0], a[1]); } ll findMin(ll from, ll to) { for(; to - from > 1;) { ll mid = (from + to) / 2; (sim(mid - 1) > sim(mid) ? from : to) = mid; } return from; } int main() { cin.tie(0); ios::sync_with_stdio(false); int ans[2]; for(k = 0; k < 2; k++) { ans[k] = findMin(0, 1000001); } assert(q(ans[0], ans[1])); }