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

public class valhalla_ak_random {

    public static char[][][] FIGURES = {
            {
                    "###".toCharArray()
            },
            {
                    "##".toCharArray()
            },
            {
                    "#.".toCharArray(),
                    "##".toCharArray()
            }
    };

    static Random rnd = new Random(3);

    static char[][] rotate(char[][] fig) {
        int n = fig.length;
        int m = fig[0].length;
        char[][] res = new char[m][n];
        return res;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            int t = in.nextInt() - 1;
            int turn = rnd.nextInt(4);
            char[][] fig = FIGURES[t];
            for (int j = 0; j < turn; j++) {
                fig = rotate(fig);
            }
            int pos = rnd.nextInt(3 - fig[0].length + 1) + 1;
            System.out.println(turn + " " + pos);
            System.out.flush();
        }
    }
}
