import java.util.Scanner;

public class lopa_ak {

    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();

        boolean chainBroken = false;

        int x = 0;

        while (x < n) {
            if (chainBroken) {
                p(x, 0);
                r();
                done();
                return;
            }
            p(x, 1);
            int[] a = r();
            if (a[0] != x + 1 || a[1] != 0) {
                chainBroken = true;
            }
            x++;
        }
        done();
    }
}
