#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) int calcX(const vector &x, const vector &y) { int ret = 0; for (int i = 0; i < x.size(); i++) ret += x[i] == y[i]; return ret; } int calcY(const vector &x, const vector &y) { int ret = 0; for (int i = 0; i < x.size(); i++) { for (int j = 0; j < y.size(); j++) { if (j == i) continue; if (x[i] == y[j]) ++ret; } } return ret; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); set > cand; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (j == i) continue; for (int k = 0; k < 10; k++) { if (k == i || k == j) continue; for (int l = 0; l < 10; l++) { if (l == i || l == j || l == k) continue; cand.insert({i, j, k, l}); } } } } while (true) { vector t = *cand.begin(); for (int i = 0; i < t.size(); i++) { if (i) cout << " "; cout << t[i]; } cout << endl; cout.flush(); int x, y; cin >> x >> y; if (x == 4 && y == 0) break; set> tmp; for (auto c: cand) { if (calcX(c, t) == x && calcY(c, t) == y) tmp.insert(c); } cand = tmp; } return 0; }