#include <bits/stdc++.h>
#define F(i,f,t) for(int i=(f),_end=(t);i<=_end;i++)
#define D(i,f,t) for(int i=(f),_end=(t);i>=_end;i--)
using namespace std;

template<typename T>
void re(T&a) {
	char c;
	T f=1;a=0;
	while(c=getchar(),!isdigit(c)) if(c=='-') f=-1;
	while(isdigit(c)) a=a*10+c-'0',c=getchar();
	a*=f;
}
template<typename T,typename ...Arg>
void re(T&a,Arg&...arg) {
	re(a),re(arg...);
}
const int N=1000,M=2e6+100;
typedef int intn[N],intm[M];
typedef pair<int,int> pii;
int n,m,k;
intm a,p,t;
bool l[M];
int fku[N][N],hd[N],ed[N];
int op[N],s1[N],s2[N],co;
bool dfs(int d) {
	if(d>m) {
		F(i,1,n) if(hd[i]<=ed[i]) return 0;
		return 1;
	}
	F(i,1,n) if(hd[i]<=ed[i]&&a[d]==fku[i][ed[i]]) {
		ed[i]--,op[++co]=1,s1[co]=i;
		if(dfs(d+1)) return 1;
		else return 0;
		fku[i][++ed[i]]=a[d],--co;
	}
	F(i,1,n) {
		fku[i][++ed[i]]=a[d],op[++co]=1,s1[co]=i;
		int dl=0;
		if(ed[i]==1) {
			F(j,1,n)if(j!=i&&hd[j]<=ed[j]&&fku[j][hd[j]]==a[d]){
				op[++co]=2,s1[co]=i,s2[co]=j;
				hd[i]++,hd[j]++,dl=j;
				break;
			}
		}
		if(dfs(d+1)) return 1;
		if(dl) fku[i][--hd[i]]=fku[dl][--hd[dl]]=a[d],--co;
		--ed[i],--co;
	}
	return 0;
}
inline void wk() {
	re(n,m,k);
	F(i,1,n) hd[i]=1,ed[i]=0;
	F(i,1,m) re(a[i]);
	co=0;
	dfs(1);
	F(i,1,co) {
		if(op[i]==1) printf("1 %d\n",s1[i]);
		else printf("2 %d %d\n",s1[i],s2[i]);
	}
}

signed main() {
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int T;
	re(T);
	while(T--) wk();
	return 0;
}
