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

using namespace std;

bool a[22][22];
int n, m, x, y;
int main()
{
	cin >> n >> m;
	cout << "2 2\n", cout.flush();
	a[1][1] = a[n][m] = a[2][2] = true;
	cin >> x >> y, a[x][y] = true;
	if (x == 1 && (y == 2 || y == 3)) cout << "1 " << 5 - y << "\n", a[1][5 - y] = true, cout.flush();
	else if (y == 1 && (x == 2 || x == 3)) cout << 5 - x << " 1\n", a[5 - x][1] = true, cout.flush();
	else cout << "1 2\n", a[1][2] = true, cout.flush();
	cin >> x >> y, a[x][y] = true;
	if (!a[1][2]) cout << "1 2\n", cout.flush(), cin >> x >> y, cout << "x_X\n", cout.flush(), exit(0); 
	if (!a[1][3]) cout << "1 3\n", cout.flush(), cin >> x >> y, cout << "x_X\n", cout.flush(), exit(0);
	if (!a[2][1]) cout << "2 1\n", cout.flush(), cin >> x >> y, cout << "x_X\n", cout.flush(), exit(0);
	if (!a[3][1]) cout << "3 1\n", cout.flush(), cin >> x >> y, cout << "x_X\n", cout.flush(), exit(0);
}