import java.util.Random;
import java.util.Scanner;

public class lopa_ak_random {

    static void p(int x, int y) {
        System.out.println((x + 1) + " " + (y + 1));
        System.out.flush();
    }

    static void done() {
        System.out.println("x_X");
        System.out.flush();
    }

    static int[] r() {
        return new int[] {in.nextInt() - 1, in.nextInt() - 1};
    }

    static Scanner in;

    public static void main(String[] args) {
        in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        Random rnd = new Random(n * m);
        boolean[][] a = new boolean[n][m];
        a[0][0] = a[n - 1][m - 1] = true;
        for (int i = 0; i < n * m / 2 - 1; i++) {
            int x, y;
            do {
                x = rnd.nextInt(n);
                y = rnd.nextInt(m);
            } while (a[x][y]);
            p(x, y);
            a[x][y] = true;
            int[] t = r();
            a[t[0]][t[1]] = true;
        }
        done();
    }

}
