#include <iostream>
#include <algorithm>
#include <stack>

using namespace std;

struct str{
	int x[2];
	int y[2];
};

int main(){
	str struc, struc1;
	int x, y;
	int v;
	stack<str> rek;
	struc.x[0] = 0;		struc.x[1] = 5;
	struc.y[0] = 0;		struc.y[1] = 5;
	rek.push(struc);
	while(!rek.empty()){
		struc = rek.top();
		rek.pop();
		if(struc.x[0] == struc.x[1]-1 && struc.y[0] == struc.y[1]-1){
			for(x = struc.x[0]; x<= struc.x[1]; x++){
				for(y = struc.y[0]; y<=struc.y[1]; y++){
					cout<<x<<' '<<y<<'\n';
					cin>>v;
					if(v == 0){
						return 0;
					}
				}
			}
			continue;
		}
		x=(struc.x[0]+struc.x[1])/2;
		y=(struc.y[0]+struc.y[1])/2;
		cout<<x<<' '<<y<<'\n';
		cout.flush();
		cin>>v;
		if(v == 0){
			return 0;
		}
		struc1 = struc;
		//dva kvadrata sta vedno ista
			struc.x[0] = x;  struc.y[1] = y;	//struc.x[1] = struc1.x[1];struc.y[0] = struc1.y[0];
				rek.push(struc);
			struc.x[0] = struc1.x[0]; struc.x[1] = x;
			struc.y[0] = y;	struc.y[1] = struc1.y[1];
				rek.push(struc);
		if(v>0){//potem nad tem in desno od tega zagotovo ni 0
			struc.x[1] = x; struc.y[0] = struc1.y[0]; struc.y[1] = y;//struc.x[0] =struc1.x[0]; 
		}
		else{//v<0
			struc.x[0] = x;  struc.x[1] = struc1.x[1];//struc.y[0] = y; struc.y[1] = struc1.y[1]
		}
		rek.push(struc);
	}
return 0;
}