#include #include #include using namespace std; const int NMAX = 200; int n, m; int val[NMAX][NMAX]; bool in_q[NMAX][NMAX]; queue < pair > q; void solve() { pair p; int right = NMAX - 1; int bottom = NMAX - 1; p.first = p.second = 0; q.push(p); while(!q.empty()) { p = q.front(); n = p.first; m = p.second; q.pop(); cout << n << ' ' << m; cout << '\n'; cout.flush(); cin >> val[n][m]; if (val[n][m] == 0) { return; } if (val[n][m] < 0) { if (n + 1 <= bottom && !in_q[n + 1][m]) { p.first = n + 1; p.second = m; q.push(p); in_q[n + 1][m] = true; } if (m + 1 < right && !in_q[n][m + 1]) { p.first = n; p.second = m + 1; q.push(p); in_q[n][m + 1] = true; } } else { bottom = max(bottom, n); right = max(right, m); } } } int main() { solve(); return 0; }