#include using namespace std; int ask( int x, int y ) { cout << x << " " << y << endl; int d; cin >> d; if( d == 0 ) { exit( 0 ); } return d; } signed main() { ios::sync_with_stdio( 0 ); int ans_x, ans_y; { map< int, int > memo; int lb = 0, ub = int( 1e5 ); while( ub - lb > 5 ) { int f = lb + ( ub - lb ) / 3; int g = lb + ( ub - lb ) / 3 * 2; int a = memo[ lb ] = memo.count( lb ) ? memo[ lb ] : ask( lb, 0 ); int b = memo[ f ] = memo.count( f ) ? memo[ f ] : ask( f, 0 ); int c = memo[ g ] = memo.count( g ) ? memo[ g ] : ask( g, 0 ); int d = memo[ ub ] = memo.count( ub ) ? memo[ ub ] : ask( ub, 0 ); if( a <= b and b <= c and c <= d ) { ub = f; } else if( a >= b and b <= c and c <= d ) { ub = g; } else if( a >= b and b >= c and c <= d ) { lb = f; } else if( a >= b and b >= c and c >= d ) { lb = g; } else { assert( 0 ); } } int mind = int( 1e5 ); for( int i = lb; i <= ub; ++i ) { int d = ask( i, 0 ); if( d < mind ) { mind = d; ans_x = i; } } } { map< int, int > memo; int lb = 0, ub = int( 1e5 ); while( ub - lb > 5 ) { int f = lb + ( ub - lb ) / 3; int g = lb + ( ub - lb ) / 3 * 2; int a = memo[ lb ] = memo.count( lb ) ? memo[ lb ] : ask( 0, lb ); int b = memo[ f ] = memo.count( f ) ? memo[ f ] : ask( 0, f ); int c = memo[ g ] = memo.count( g ) ? memo[ g ] : ask( 0, g ); int d = memo[ ub ] = memo.count( ub ) ? memo[ ub ] : ask( 0, ub ); if( a <= b and b <= c and c <= d ) { ub = f; } else if( a >= b and b <= c and c <= d ) { ub = g; } else if( a >= b and b >= c and c <= d ) { lb = f; } else if( a >= b and b >= c and c >= d ) { lb = g; } else { assert( 0 ); } } int mind = int( 1e5 ); for( int i = lb; i <= ub; ++i ) { int d = ask( 0, i ); if( d < mind ) { mind = d; ans_y = i; } } } assert( ask( ans_x, ans_y ) == 0 ); return 0; }