#include<bits/stdc++.h>
#define nm 300000
using namespace std;
void read(int &n){
	char ch=getchar();
	int k=0,f=1;
	while(ch<'0' or ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0' and ch<='9'){
		k=k*10+ch-'0';
		ch=getchar();
	}
	n=f*k;
}
int a[nm*20],b,c,d,e,f,g,h,T,k,bj[nm],lx[nm],num[nm];
int cnt;
struct data{
	int p,s1,s2;
}ans[nm*20];
int q[nm][3];
bool s;
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	read(T);
	while(T--){
		cnt=0;
		read(b);
		read(c);
		read(k);
		for(int i=1;i<=c;i++){
			read(a[i]);
		}
		if(k==2*b-2){
			for(int i=1;i<=c;i++){
				s=0;
				for(int j=1;j<b;j++){
					if(q[j][0]==a[i]){
						ans[++cnt]={1,b,0};
						ans[++cnt]={2,b,j};
						q[j][0]=q[j][1];
						lx[j]--;
						s=1;
						break;
					}
					if(q[j][1]==a[i]){
						cnt++;
						ans[++cnt]={1,j,0};
						s=1;
						lx[j]--;
						break;
					}
				}
				if(!s)for(int j=1;j<b;j++){
					if(lx[j]==0){
						ans[++cnt]={1,j,0};
						q[j][0]=a[i];
						lx[j]++;
						s=1;
						break;
					}
				}
				if(!s){
					for(int j=1;j<b;j++){
						if(lx[j]==1){
								ans[++cnt]={1,j,0};
							q[j][1]=a[i];
							lx[j]++;
							break;
						}
					}
				}
			}
			printf("%d\n",cnt);
			for(int i=1;i<=cnt;i++){
				if(ans[i].p==1){
					printf("1 %d",ans[i].s1);
				}
				else{
					printf("2 %d %d",ans[i].s1,ans[i].s2);
				}
				putchar('\n');
			}
		}
	}
}
//1
//2 4 2
//1 2 1 2