#include using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); vector data = {9, 8, 7, 6}; vector known; for (int i = 0; i < 4; i++) { int xy = -1; int know = data.back(); int limit = data.back(); for (int num = 0; num <= limit; num++) { if (find(known.begin(), known.end(), num) != known.end()) continue; data.back() = num; for (int idx = 0; idx < 4; idx++) { cout << data[idx]; if (idx == 3) cout << endl; else cout << " "; } int X, XY; cin >> X >> XY; if (X == 4) return 0; XY += X; if (xy < XY) { xy = XY; know = num; } } data.pop_back(); data.insert(data.begin(), know); known.push_back(know); } do { for (int idx = 0; idx < 4; idx++) { cout << known[idx]; if (idx == 3) cout << endl; else cout << " "; } int X, Y; cin >> X >> Y; if (X == 4) break; } while (next_permutation(known.begin(), known.end())); return 0; }