#include<bits/stdc++.h>
#define ll long long
#define IN inline
#define rg register
#define re(i,a,b) for(rg int i=a,i##up=b;i<=i##up;i++)
#define er(i,a,b) for(rg int i=a,i##dw=b;i>=i##dw;i--)
#define go(i,x) for(rg int i=head[x];i;i=nxt[i])
#define mem(a,x) memset(a,x,sizeof a)
const int N=300+5,M=2e6+5;
IN ll read(){
	rg ll res=0,f=1; rg char c; do f&=((c=getchar())!='-'); while(c<'0' || '9'<c);
	for(;'0'<=c && c<='9';res=res*10+(c^48),c=getchar()); return f?res:-res;
}
int n,m,k,a[M],cnt;
struct opt{
	int o,s1,s2;
}op[M<<1];
namespace S1{
	int st[N],len[N];
	void sol(){
		re(i,1,m){
			int k=(a[i]+1)>>1;
			if(!st[k]){
				st[k]=a[i],len[k]=1;
				op[++cnt]=(opt){1,k,0};
			}else if(a[i]==st[k]){
				op[++cnt]=(opt){1,n,0},op[++cnt]=(opt){2,k,n};
				st[k]=(--len[k])?((a[i]+1)^1)-1:0;
			}else op[++cnt]=(opt){1,k,0},len[k]++;
		}
		printf("%d\n",cnt);
		re(i,1,cnt) op[i].o==1?printf("1 %d\n",op[i].s1):printf("2 %d %d\n",op[i].s1,op[i].s2);
		cnt=0,mem(st,0),mem(len,0);
	}
}
namespace S2{
	int q[N],l,r;
	void sol(){
		l=1,r=0;
		re(i,1,m){
			if(l>r || (q[l]^a[i] && q[r]^a[i])){
				q[++r]=a[i];
				op[++cnt]=(opt){1,1,0};
			}else if(a[i]==q[l]){
				op[++cnt]=(opt){1,2,0},op[++cnt]=(opt){2,1,2},l++;
			}else if(a[i]==q[r]){
				op[++cnt]=(opt){1,1,0},r-=2,q[r+1]=q[r+2]=0;
			}
		}
		printf("%d\n",cnt);
		re(i,1,cnt) op[i].o==1?printf("1 %d\n",op[i].s1):printf("2 %d %d\n",op[i].s1,op[i].s2);
		cnt=0,mem(q,0);
	}
}
//namespace S3{
//	
//}
int main(){
	freopen("meow.in","r",stdin),freopen("meow.out","w",stdout);
	for(int T=read(),id=T%10;T--;){
		n=read(),m=read(),k=read(); re(i,1,m) a[i]=read();
		if(id==1){S1::sol(); continue;}
		if(id==2){S2::sol(); continue;}
		
	}
	return 0;
}
