#include using namespace std; signed main(){ set< tuple< int, int, int, int > > cand; for( int i = 0; i < 10; ++i ) for( int j = 0; j < 10; ++j ) if( j != i ) for( int k = 0; k < 10; ++k ) if( k != i and k != j ) for( int l = 0; l < 10; ++l ) if( l != i and l != j and l != k ) cand.emplace( i, j, k, l ); while( not cand.empty() ){ int a, b, c, d; tie( a, b, c, d ) = *cand.begin(); cout << a << " " << b << " " << c << " " << d << endl; int x, y; cin >> x >> y; // exactly same / different pos but has if( x == 4 and y == 0 ) exit( 0 ); set< tuple< int, int, int, int > > ncand; for( auto it = cand.begin(); it != cand.end(); ++it ){ int sx = 0, sy = 0; int e, f, g, h; tie( e, f, g, h ) = *it; sx = ( a == e ) + ( b == f ) + ( c == g ) + ( d == h ); if( a != e and ( a == f or a == g or a == h ) ) ++sy; if( b != f and ( b == e or b == g or b == h ) ) ++sy; if( c != g and ( c == e or c == f or c == h ) ) ++sy; if( d != h and ( d == e or d == f or d == g ) ) ++sy; if( sx == x and sy == y ) ncand.emplace( e, f, g, h ); } swap( cand, ncand ); } return 0; }