// Arup Guha
// 4/7/2018
// Solution to 2018 Code Jam Qualification Problem: Gopher

// Written in contest, commented afterwards.
import java.util.*;

public class Solution {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		boolean bad = false;

		// Process all cases.
		for (int i=1; i<=nC; i++) {

			// Set up - strategy to fill a 3 x n rectangle.
			int area = stdin.nextInt();
			int len = Math.max(3,(area+2)/3);
			int filled = 0, checkcol = 0;
			boolean[][] cur = new boolean[3][100];
			
			// Main loop for a case.
			while (true) {

				// Always guess on row 2 at our current column...
				int where = checkcol < len-2 ? checkcol+2 : len-1;
				System.out.println("2 "+(where));
				System.out.flush();

				int x = stdin.nextInt()-1;
				int y = stdin.nextInt()-1;

				// This means we are done with this case.
				if (x == -1 && y == -1) break;

				// We messed up.
				if (x == -2) {
					bad = true;
					break;
				}
				
				// Fill this square.
				if (!cur[x][y]) filled++;
				cur[x][y] = true;

				// Figure out which column our next guess will be in.
				checkcol = getcheckcol(cur, checkcol);
			}

			// Get out.
			if (bad) break;
		}

	}

	// Go to the first column that isn't fully filled.
	public static int getcheckcol(boolean[][] cur, int c) {
		while (cur[0][c] && cur[1][c] && cur[2][c]) c++;
		return c;
	}
}