#include using namespace std; #define rep(i,a,b) for(int i=a;i vi; typedef pair pii; int main() { set nouse; rep(a, 0, 9) rep(b, a + 1, 10) { vi n; rep(i, 0, 10) { if (i == a) continue; if (i == b) continue; n.push_back(i); } rep(i, 0, 4) cout << n[i]; int x, y; cin >> x >> y; if (x == 4) return 0; if (y == 0) { rep(j, 0, 4) nouse.insert(n[j]); } rep(i, 0, 4) cout << n[i + 4]; int xx, yy; cin >> xx >> yy; if (xx == 4) return 0; if (yy == 0) { rep(j, 0, 4) nouse.insert(n[j]); } if (y + yy == 4) { nouse.insert(a); nouse.insert(b); } if (nouse.size() == 6) break; } vector use; rep(i, 0, 10) if (nouse.find(i) == nouse.end()) use.push_back(i); rep(i, 0, 4) rep(j, 0, 4) rep(ii, 0, 4) rep(jj, 0, 4) { if (i == j) continue; if (i == ii) continue; if (i == jj) continue; if (j == ii) continue; if (j == jj) continue; if (ii == jj) continue; cout << use[i]; cout << use[j]; cout << use[ii]; cout << use[jj]; int x, y; cin >> x >> y; if (x == 4) return 0; } }