#include using namespace std; #define rep(i,a,b) for(int i=a;i vi; typedef vector vs; typedef pair pii; vs make_str(vi a, int num) { queue que; que.push(""); rep(i, 0, num) { queue q; while (!que.empty()) { string s = que.front(); que.pop(); for (int aa : a) q.push(s + " " + to_string(aa)); } que = q; } vs ret; while (!que.empty()) { string s = que.front(); que.pop(); ret.push_back(s); } return ret; } int main() { cout << "0 1 2 3" << endl; int x, y; cin >> x >> y; if (x == 4) return 0; cout << "4 5 6 7" << endl; int xx, yy; cin >> xx >> yy; if (xx == 4) return 0; set use; vs a = make_str(vi{ 0, 1, 2, 3 }, y); vs b = make_str(vi{ 4, 5, 6, 7 }, yy); vs c = make_str(vi{ 8, 9 }, 4 - y - yy); for (string sa : a) for (string sb : b) for(string sc : c) { cout << sa; cout << sb; cout << sc; cout << endl; int x, y; cin >> x >> y; if (x == 4) return 0; if (y == 4) { rep(i, 0, 4) if (sa.find(to_string(i)) != string::npos) use.insert(i); rep(i, 4, 8) if (sb.find(to_string(i)) != string::npos) use.insert(i); rep(i, 8, 10) if (sc.find(to_string(i)) != string::npos) use.insert(i); } } vi nums; for (int i : use) nums.push_back(i); rep(i, 0, 4) rep(j, 0, 4) rep(k, 0, 4) rep(l, 0, 4) { if (i == j) continue; if (i == k) continue; if (i == l) continue; if (j == k) continue; if (j == l) continue; if (k == l) continue; printf("%d %d %d %d\n", nums[i], nums[j], nums[k], nums[l]); if (x == 4) return 0; } }