#include<bits/stdc++.h>
using namespace std;
const int N=310,K=610,M=2e6+5;
int t,n,m,k,p,a[M],x;
deque<int>q[N];
void get1(int i){printf("1 %d\n",i),q[i].push_back(x);}
void get2(int i,int j){
	printf("2 %d %d\n",i,j),q[i].pop_front(),q[j].pop_front();
}
signed main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	scanf("%d",&t);
	while(t--){
		scanf("%d%d%d",&n,&m,&k);
		for(int i=1;i<=m;i++)
			scanf("%d",&a[i]);
		for(int i=1;i<=m;i++){
			x=a[i],p=(x+1)/2;
			if(q[p].size()){
				if(q[p].back()==x) get1(p),q[p].pop_back(),q[p].pop_back();
				else if(q[p].front()==x) get1(n),get2(p,n);
				else get1(p);
			}
			else get1(p);
		}
	}
	return 0;
}