// Arup Guha
// 3/27/2021
// Solution to 2021 Code Jam Qualifying Question: Median Sort
// Just good enough for small data.

import java.util.*;

public class Solution {

	public static Scanner stdin;

	public static void main(String[] args) {
	
		// Get basic parameters.
		stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		int n = stdin.nextInt();
		int q = stdin.nextInt();
		
		// Do cases.
		for (int loop=1; loop<=nC; loop++) {
		
			// Get first median.
			System.out.println("1 2 3");
			System.out.flush();
			int mid = stdin.nextInt();
			
			// Hard-code list.
			ArrayList<Integer> res = new ArrayList<Integer>();
			if (mid == 1) {
				res.add(2); res.add(1); res.add(3);
			}
			else if (mid == 2) {
				res.add(1); res.add(2); res.add(3);
			}
			else {
				res.add(1); res.add(3); res.add(2);
			}
			
			// Figuring out where x goes.
			for (int x=4; x<=n; x++) {
				insert(res, 0, (x-2)/3, (2*(x-2))/3, x-2, x);
			}
			
			// Ta da!
			for (int i=0; i<res.size()-1; i++)
				System.out.print(res.get(i)+" ");
			System.out.println(res.get(n-1));
			
			int response = stdin.nextInt();
			if (response == -1) break;
		}
	}
	
	public static void insert(ArrayList<Integer> list, int realLow, int low, int high, int realHigh, int curIdx) {
	
		// This guess.
		System.out.println(list.get(low)+" "+list.get(high)+" "+curIdx);
		System.out.flush();
		int mid = stdin.nextInt();
		
		// We're close, so no more recursion.
		if (realLow+1 == realHigh) {
			if (mid == curIdx) list.add(realLow+1, curIdx);
			else if (mid == list.get(realLow)) list.add(realLow, curIdx);
			else list.add(realHigh+1, curIdx);
			return;
		}
		
		// Number goes to the left.
		if (mid == list.get(low)) {
			if (low == realLow) 	list.add(realLow, curIdx);
			else if (realLow+1 == low) insert(list, realLow, realLow, low, low, curIdx);
			else 			insert(list, realLow, (2*realLow+low)/3, (realLow+2*low)/3, low, curIdx);
		}
		
		// Number goes to the right.
		else if (mid == list.get(high)) {
			if (high == realHigh) 	list.add(realHigh+1,curIdx);
			else if (high+1 == realHigh) insert(list, high, high, realHigh, realHigh, curIdx);
			else 						insert(list, high, (2*high+(list.size()-1))/3, (high+2*(list.size()-1))/3 ,list.size()-1, curIdx);
		}
		
		// Number goes in between!
		else {
			if (low+1 == high) 	list.add(low+1, curIdx);
			else if (low+2 == high) insert(list, low, low, high-1, high-1, curIdx);
			else 				insert(list, low, (2*low+high)/3, (low+2*high)/3, high, curIdx);
		}
	}

}