#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using pii = pair; constexpr ll INF = 1ll<<30; constexpr ll longINF = 1ll<<60; constexpr ll MOD = 1000000007; constexpr bool debug = false; //---------------------------------// int main() { int dbans[4]{}; auto query = [&](int a, int b, int c, int d) -> pii { if (debug) { int X = 0, Y = 0; int ary[4] {a, b, c, d}; REP(i, 4) X += dbans[i] == ary[i]; REP(i, 4) FOR(j, i + 1, 4) if (i != j) Y += dbans[i] == ary[j]; return {X, Y}; } else { printf("%d %d %d %d\n", a, b, c, d); fflush(stdout); int X, Y; scanf("%d %d", &X, &Y); if (X == 4 && Y == 0) exit(0); return {X, Y}; } }; auto solve = [&]() { vector x, y; FOR(i, 3, 10) { auto [X, Y] = query(0, 1, 2, i); x.emplace_back(X); y.emplace_back(Y); } int minx = *min_element(ALL(x)), miny = *min_element(ALL(y)); vector pred; FOR(i, 3, 10) if (x[i - 3] == minx && y[i - 3] == miny) pred.emplace_back(i); assert(pred.size() >= 3); // printf("%d %d %d\n", pred[0], pred[1], pred[2]); int ans[4]; bool done[10] {}; REP(i, pred.size()) done[pred[i]] = true; REP(t, 4) { int N[4]; REP(i, 4) if (t != i) N[i] = pred[i - (i > t)]; REP(i, 10) { if (done[i]) continue; N[t] = i; auto [x, y] = query(N[0], N[1], N[2], N[3]); // printf(" %d %d %d %d, %d %d\n", N[0], N[1], N[2], N[3], x, y); assert(x == 0 && y == 0 || x == 0 && y == 1 || x == 1 && y == 0); if (x == 1) { ans[t] = i; done[i] = true; break; } } } auto [a, b] = query(ans[0], ans[1], ans[2], ans[3]); if (debug && (a != 4 || b != 0)) { REP(i, 4) printf("%d ", ans[i]); puts(""); assert(false); } }; bool d[10] {}; auto dfs = [&](auto self, int k) -> void { if (k == 4) { // printf("start %d %d %d %d\n", dbans[0], dbans[1], dbans[2], dbans[3]); solve(); // printf("done %d %d %d %d\n", dbans[0], dbans[1], dbans[2], dbans[3]); return; } REP(i, 10) { if (d[i]) continue; d[i] = true; dbans[k] = i; self(self, k + 1); d[i] = false; } }; if (debug) { dfs(dfs, 0); puts("OK"); } else solve(); }