#include<bits/stdc++.h>
using namespace std;
struct node{
	int size,x,y;
};
bool t;
node st[1000];
int n,m,i,j,k,ans,T;
int a[1000],head[1000],tail[1000],z[500][10000];
/*void check(int step,int k){
	if(down[a[k]]>0){
		ans++;
		st[ans].size=2;
		st[ans].x=k;
		st[ans].y=down[a[k]];
		tail[down[a[k]]]++;
		int x=z[down[a[k]]][tail[down[a[k]]]];
		down[a[k]]*=-1;
		check(step,x);
		down[a[k]]*=-1;
		tail[down[a[k]]]--;
		ans--;
	}else go(step+1);
}*/
void go(int step){
	if(step>m){
		/*for(int i=1;i<=n;i++){
			cout<<head[i]<<" "<<tail[i]<<endl;
			//for(int j=tail[i];i<=head[i];j++)
			  //  cout<<z[i][j]<<" ";
			cout<<endl;
		}
		cout<<endl;*/
		t=true;
		for(int i=1;i<=n;i++)
		    if(head[i]!=tail[i]-1){t=false;break;}
		if(t){
			printf("%d\n",ans);
			for(int i=1;i<=ans;i++)
				if(st[i].size==1)printf("1 %d\n",st[i].x);
				else printf("2 %d %d\n",st[i].x,st[i].y);
		}
		return;
	}
	for(int i=1;i<=n;i++){
		//if(i==3&&step==3)cout<<"AAAAAAAA"<<endl;
		/*if(head[i]==tail[i]-1){
			int j=step,k=0;
			bool f[10];
			while(down[a[j]]>0){
				ans++;k++;
	        	st[ans].size=2;
	        	st[ans].x=k;
        		st[ans].y=down[a[k]];
		        tail[down[a[k]]]++;
		        f[down[a[k]]]++;
        		j=z[down[a[k]]][tail[down[a[k]]]];
		        down[a[k]]*=-1;
			}
			head[i]++;
			z[i][head[i]]=step;
			bool tt=true;
			while(tt){
				for(int i1=1;i1<=n;i1++){
					if()
				}
			}
		}else */if(a[z[i][head[i]]]==a[step]&&head[i]>=tail[i]){
			ans++;
			st[ans].size=1;
			st[ans].x=i;
			head[i]--;
			go(step+1);
			head[i]++;
			ans--;
		}else{
			head[i]++;
			z[i][head[i]]=step;
			ans++;
			st[ans].size=1;
			st[ans].x=i;
			go(step+1);
			ans--;
			head[i]--;
		}
        if(t)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);
		/*if(n==2){
	    	for(i=1;i<=m;i++){
    		    scanf("%d",&a[i]);
	    	    t[i]=true;
		        if(a[i]==a[i-1]&&t[i-1]){
		        	f[i]=f[i-1]=1;
		    	    t[i]=t[i-1]=false;
    			}
	    }else{*/
	    for(i=1;i<=n;i++)
	        tail[i]=1;
	    for(i=1;i<=m;i++)
	   	    scanf("%d",&a[i]);
	   	go(1);
		//}
	}
}
