#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<deque>
using namespace std;
int T,n,m,k,ccc=0;
queue<int> q;
struct zwh{
	int s,x,y;
}a[4000010];
deque<int> qq[310];
bool check(){
	if(q.empty()){
		for(int i=1;i<=n;i++)
			if(!qq[i].empty())
				return false;
		return  true;
	}
	return  false;
}
void dfs(int x){
	if(x>2*m) return;
	if(check()&&x>=m){
		for(int i=0;i<x;i++){
			printf("%d %d",a[i].s,a[i].x);
			if(a[i].s==2)printf(" %d\n",a[i].y);
			else printf("\n");
		}
		ccc=1;
		return;
	}
	if(!q.empty()){
		queue<int> opop;
		opop=q;
		int v=q.front();q.pop();
		for(int i=1;i<=n;i++){
			a[x].s=1;
			a[x].x=i;
			deque<int> jk,lk;
//			swap(jk,qq[i]);
//			cout<<"qq["<<i<<"]:=";
//			while(!jk.empty()){
//				int l=jk.front();jk.pop_front();
//				qq[i].push_back(l);
//				lk.push_back(l);
//				cout<<l<<" ";
//			}
			lk=qq[i];
//			cout<<q.empty()<<" "<<x<<"=-="<<i<<" "<<v;
//			if(!qq[i].empty())cout<<" "<<qq[i].back()<<endl;
//			else cout<<endl;
			if(!qq[i].empty()&&qq[i].back()==v) qq[i].pop_back();
			else qq[i].push_back(v);
			dfs(x+1);
			if(ccc) return;
			swap(qq[i],lk);
			a[x].s=0;
			a[x].x=0;
		}
		q=opop;
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(!qq[i].empty()&&!qq[j].empty()&&qq[i].front()==qq[j].front()){
				a[x].s=2;
				a[x].x=i;
				a[x].y=j;
				deque<int> lk,jk;
//				swap(lk,qq[i]);swap(jk,qq[j]);
				lk=qq[i];jk=qq[j];
				qq[i].pop_front();qq[j].pop_front();
				dfs(x+1);
				if(ccc) return;
				qq[i]=lk;
				qq[j]=jk;
				a[x].s=0;
				a[x].x=0;
				a[x].y=0;
			}
		}
	}
	return;
}
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	
	scanf("%d",&T);
	while(T--){
		scanf("%d%d%d",&n,&m,&k);
		queue<int>lll;
		deque<int>llll;
		q=lll;
		ccc=0;
		for(int i=1;i<=n;i++) qq[i]=llll;
//		cout<<n<<' '<<m<<" "<<k<<endl;
		for(int i=1;i<=m;i++){
			int x;
			scanf("%d",&x);
			q.push(x);
		}
		dfs(0);
//		if(!ccc) cout<<"no"<<endl;
	}
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}