#include<bits/stdc++.h>
using namespace std;
int t;
int n,m,k;
int stuc[350][2];//1->top,0->bottom,first to top and then to bottom
int le[200]{0};
int qwq(){
	int w=0;
	for(int i=1;i<=n;i++){
		if(stuc[i][0]==0){
			w=i;
			break;
		}
	}
	return w;
}
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	cin>>t;
	while(t--){
		cin>>n>>m>>k;
		for(int i=1;i<=n;i++)stuc[i][0]=stuc[i][1]=0;
		for(int i=1;i<=m;i++){
			int qr;
			cin>>qr;
			if(le[qr]!=0&&le[qr]%2==1){//qr exist and the top
				cout<<"1 "<<le[qr]/2+1<<endl;
				if(stuc[le[qr]/2+1][0]==0){
					stuc[le[qr]/2+1][1]==0;
				}
				else{
					int eg=stuc[le[qr]/2+1][0];
					stuc[le[qr]/2+1][1]=eg;
					stuc[le[qr]/2+1][0]=0;
					le[eg]--;
				}
				le[qr]=0;
			}
			else if(le[qr]!=0&&le[qr]%2==0){//qr exist and the bottom
				cout<<"1 "<<n<<endl<<"2 "<<le[qr]/2<<" "<<n<<endl;
				stuc[le[qr]/2][0]=0;
				le[qr]=0;
			}
			else if(le[qr]==0){//qr inexist
				int pl=qwq();
				if(stuc[pl][1]==0){
					stuc[pl][1]=qr;
					le[qr]=pl*2-1;
				}
				else{
					le[stuc[pl][1]]++;
					stuc[pl][0]=stuc[pl][1];
					stuc[pl][1]=qr;
					le[qr]=pl*2-1;
				}
				cout<<"1 "<<pl<<endl;
			}
		}
	}
	return 0;
}