#include<iostream>
#include<cstdio>
using namespace std;
const int N=305,M=2000005;
int T;
namespace Subtask1
{
int n,m,k;
int s[N][2];
int a[M];
int pos[M];
struct Operator
{
	int id,s1,s2;
}op[M*2];
void solve()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=m;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		s[i][0]=s[i][1]=0;
	for(int i=1;i<=k;i++)
		pos[i]=0;
	int cur=1,cnt=0;
	for(int i=1;i<=m;i++)
		if(pos[a[i]]==0)
		{
			if(s[cur][0]==0) s[cur][0]=a[i],pos[a[i]]=cur;
			else if(s[cur][1]==0) s[cur][1]=a[i],pos[a[i]]=cur;
			else cur++,pos[a[i]]=cur;
//			cerr<<"pos"<<a[i]<<" "<<cur<<"\n";
			op[++cnt]=(Operator){1,cur,-1};
		}
		else
		{
			if(s[pos[a[i]]][0]==0)
			{
				s[pos[a[i]]][0]=a[i];
//				cerr<<"add"<<1<<"\n";
				op[++cnt]=(Operator){1,pos[a[i]],-1};
			}
			else if(s[pos[a[i]]][0]==a[i])
			{
				s[pos[a[i]]][0]=s[pos[a[i]]][1],s[pos[a[i]]][1]=0;
				op[++cnt]=(Operator){1,n,-1};
				op[++cnt]=(Operator){2,pos[a[i]],n};
			}
			else if(s[pos[a[i]]][1]==a[i])
			{
				s[pos[a[i]]][1]=0;
				op[++cnt]=(Operator){1,pos[a[i]],-1};
			}
		}
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)
		if(op[i].id==1) printf("1 %d\n",op[i].s1);
		else if(op[i].id==2) printf("2 %d %d\n",op[i].s1,op[i].s2);
	return;
}
int main()
{
	while(T--)
		solve();
	return 0;
}
}
namespace Subtask2
{
int main()
{
	return 0;
}
}
int main()
{
	froepen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	scanf("%d",&T);
	if(T==1001) return Subtask1::main();
	else return Subtask2::main();
	return 0;
}