#include <iostream>
#include <queue>

using namespace std;

const int NrMax = 200;

int main() {
	int n, m;
	int Value[NrMax][NrMax];
	bool j[NrMax][NrMax];
	queue < pair <int, int> > q;
	
	
	pair <int, int> p;
    int right = NrMax - 1;
    int bottom = NrMax - 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 >> Value[n][m];

        if (Value[n][m] == 0) {
            break;
        }
        if (Value[n][m] < 0) {
            if (n + 1 <= bottom && !j[n + 1][m]) {
                p.first = n + 1;
                p.second = m;
                q.push(p);
                j[n + 1][m] = true;
            }
            if (m + 1 < right && !j[n][m + 1]) {
                p.first = n;
                p.second = m + 1;
                q.push(p);
                j[n][m + 1] = true;
            }
        }
        else {
            bottom = max(bottom, n);
            right = max(right, m);
        }
    }
	return 0;
}