#include #include #include #include void print(int a, int b, int c, int d) { std::cout << a << " " << b << " " << c << " " << d << std::endl; } int main() { int a = 0, b = 1, c = 2, d = 3; int hit, blow; print(a, b, c, d); std::cin >> hit >> blow; if (hit == 4) return 0; int h, bl, pre; while(d < 10) { print(a, b, c, d); std::cin >> h >> bl; if (h == 4) return 0; if (h + bl > hit + blow) { hit = h; blow = b; break; } if (h + bl < hit + blow) { d = pre; break; } pre = d; d++; } while (c < 10) { if (c == d) { c++; continue; } print(a, b, c, d); std::cin >> h >> bl; if (h == 4) return 0; if (h + bl > hit + blow) { hit = h; blow = b; break; } if (h + bl < hit + blow) { c = pre; break; } pre = c; c++; } while (b < 10) { if (b == c || b == d) { b++; continue; } print(a, b, c, d); std::cin >> h >> bl; if (h == 4) return 0; if (h + bl > hit + blow) { hit = h; blow = b; break; } if (h + bl < hit + blow) { b = pre; break; } pre = b; b++; } while (a < 10) { if (a == b || a == c || a == d) { a++; continue; } print(a, b, c, d); std::cin >> h >> bl; if (h == 4) return 0; if (h + bl > hit + blow) { hit = h; blow = b; break; } if (h + bl < hit + blow) { a = pre; break; } pre = a; a++; } std::vector v; v.push_back(a); v.push_back(b); v.push_back(c); v.push_back(d); std::sort(v.begin(), v.end()); do { print(v[0], v[1], v[2], v[3]); std::cin >> h >> bl; if (h == 4) return 0; } while (std::next_permutation(v.begin(), v.end())); return 0; }