#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=310;
struct op{
	int x,y,z;
} b[N];
int n,m,k,a[N],c[4][N],l[4],r[4];
bool flag;
void dfs(int x,int y,int z){
	//printf("%d%d%d\n",x,y,z);
	if(flag) return;
	int i,j,R;
	if(x==m+1 && !y){
		printf("%d\n",z);
		for(int i=1;i<=z;++i){
			if(b[i].x==1) printf("1 %d\n",b[i].y);
			else printf("2 %d %d\n",b[i].y,b[i].z);
		}
		flag=1;
		return;
	}
	/*for(i=1;i<=n;++i){
		cout<<l[i]<<' '<<r[i]<<endl;
		for(j=l[i];j<=r[i];++j) printf("%d ",c[i][j]);
		puts("");
	}
	puts("");*/
	if(x<=m){
		for(i=1;i<=n;++i){
			R=r[i],c[i][++r[i]]=a[x],b[z+1].x=1,b[z+1].y=i;
			if(c[i][r[i]]==c[i][r[i]-1]){
				r[i]-=2;
				dfs(x+1,y-1,z+1);
			}
			else dfs(x+1,y+1,z+1);
			if(flag) return;
			r[i]=R;
		}
	}
	for(i=1;i<n;++i){
		if(l[i]>r[i]) continue;
		for(j=i+1;j<=n;++j)
			if(l[j]<=r[j] && c[i][l[i]]==c[j][l[j]]){
				++l[i],++l[j],b[z+1].x=2,b[z+1].y=i,b[z+1].z=j;
				dfs(x,y-2,z+1);
				if(flag) return;
				--l[i],--l[j];
			}
	}
}
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int T,i,j;
	scanf("%d",&T);
	while(T--){
		flag=0;
		memset(c,0,sizeof c);
		scanf("%d%d%d",&n,&m,&k);
		for(i=1;i<=n;++i) l[i]=1,r[i]=0;
		for(i=1;i<=m;++i)
			scanf("%d\n",&a[i]);
		dfs(1,0,0);
	}
	return 0;
}