#include using namespace std; #define ll long long #define pb push_back #define mp make_pair #define pii pair #define pll pair #define all(x) (x).begin(), (x).end() #define fi first #define se second int n = 5; bool found = 0; void solve(int a, int b, int c, int d) { if (found) return; int row = (a + c) / 2; int l = b; int r = d; int pos = -1; while (l <= r) { int mi = (l + r) / 2; cout << row << " " << mi << '\n'; cout.flush(); int val; cin >> val; if (val == 0) { found = 1; return; } if (val > 0) { pos = mi; r = mi - 1; } else l = mi + 1; } if (pos == -1) { if (row + 1 <= c) solve(row + 1, b, c, d); } else { if (row + 1 <= c && b <= pos - 1) solve(row + 1, b, c, pos - 1); if (found) return; if (a <= row - 1 && pos <= d) solve(a, pos, row - 1, d); } } int main() { cin.sync_with_stdio(false); solve(0, 0, n - 1, n - 1); return 0; }