//7~10 15opts
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N=305;
const int M=2e6+10;

int n,m,k;
int a[M],ans[M<<1][4],sum;
int st[3][M],h[3],e[3];
int ud[3][N];

void into(){
	scanf("%lld%lld%lld",&n,&m,&k);
	for(int i=1;i<=m;++i)	scanf("%lld",&a[i]);
}

void ad(int o,int x,int y){
	ans[++sum][0]=o;
	ans[sum][1]=x;
	if(o==2)	ans[sum][2]=y;
}

void out(){
	printf("%lld\n",sum);
	for(int i=1;i<=sum;++i){
		printf("%lld %lld",ans[i][0],ans[i][1]);
		if(ans[i][0]==2)	printf(" %lld",ans[i][2]);
		puts("");
	}
}

void init(){
	sum=n=m=k=0;
	memset(ans,0,sizeof(ans));
	memset(st,0,sizeof(st));
	memset(h,0,sizeof(h));
	memset(e,0,sizeof(e));
	memset(ud,0,sizeof(ud));
	memset(a,0,sizeof(a));
}

void solve2(){
	init();
	into();
	for(int i=1;i<=m;++i){
		int p=0;
		for(int j=1;j<=2&&p==0;++j){
			if(!ud[j][a[i]]){
				ad(1,j,0);
				st[j][++e[j]]=a[i];
				ud[j][a[i]]=1;
				p=1;
			}
			else if(st[j][h[j]+1]==a[i]){
				ad(1,3-j,0);
				ad(2,j,3-j);
				ud[j][st[j][h[j]]]=0;
				++h[j];
				p=1;
			}
			else if(st[j][e[j]]==a[i]){
				ad(1,j,0);
				ud[j][st[j][e[j]]]=0;
				--e[j];
				p=1;
			}
		}
	}
}

signed main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int t;scanf("%lld",&t);
	while(t--){
		solve2();
		out();
	}
	return 0;
}
