#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

bool a[22][22];
int n, m, x, y;

void print(int x, int y)
{
	cout << x << " " << y << endl;
	a[x][y] = true;
}

void go(int x, int y)
{
	if (a[x][y]) return;
	print(x, y);
	cin >> x >> y, cout << "x_X" << endl;
	exit(0);
}

int main()
{
	cin >> n >> m;
	print(2, 2);
	cin >> x >> y, a[x][y] = true;
	if (x == 1 && (y == 2 || y == 3)) print(1, 5 - y);	
	else if (y == 1 && (x == 2 || x == 3)) print(5 - x, 1);
		 else print(1, 2);
	cin >> x >> y, a[x][y] = true;
	go(2, 1), go(3, 1), go(1, 2), go(1, 3);
}
