#include <bits/stdc++.h>
using namespace std;
const int MAXM=2000010;
const int MAXN=310;
struct opt{
	int type;
	int x,y;
}ans[2*MAXM];
int T,cnt;
int n,m,k;
int a[MAXM];

int g[MAXN][5];
int tp[MAXN];
int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	scanf("%d",&T);
	if(T%10==1)
	{
		while(T--)
		{
			scanf("%d %d %d",&n,&m,&k);
			cnt=0;
			memset(g,0,sizeof(g));
			memset(tp,0,sizeof(tp));
			while(m--)
			{
//				for(int x1=1;x1<=n;x1++) printf("%d ",tp[x1]);
//				printf("\n");
				int val;
				scanf("%d",&val);
				int sk=(val+1)/2;
				if(tp[sk]==0)
				{
					opt tmp;
					tmp.type=1,tmp.x=sk;
					ans[++cnt]=tmp;
					tp[sk]++;
					g[sk][tp[sk]]=val;
				}
				else if(g[sk][tp[sk]]==val)
				{
					opt tmp;
					tmp.type=1,tmp.x=sk;
					ans[++cnt]=tmp;
					tp[sk]--;
				}
				else if(g[sk][tp[sk]]!=val && g[sk][1]==val)
				{
					opt tmp;
					tmp.type=1,tmp.x=n;
					ans[++cnt]=tmp;
					tmp.type=2,tmp.x=sk,tmp.y=n;
					ans[++cnt]=tmp;
					tp[sk]--;
				}
				else
				{
					opt tmp;
					tmp.type=1,tmp.x=sk;
					ans[++cnt]=tmp;
					tp[sk]++;
					g[sk][tp[sk]]=val;
				}
			}
			printf("%d\n",cnt);
			for(int x1=1;x1<=cnt;x1++)
			{
				if(ans[x1].type==1) printf("1 %d\n",ans[x1].x);
				else if(ans[x1].type==2) printf("2 %d %d\n",ans[x1].x,ans[x1].y);
			}
		}
		return 0;
	}
	/*if(T%10==2)
	{
		int s1[10],s2[10];
		int tp1=0,tp2=0;
		while(T--)
		{
			scanf("%d %d %d",&n,&m,&k);
			cnt=0;
			for(int x1=1;x1<=m;x1++) scanf("%d",&a[x1]);
			for(int x1=1;x1<=n;x1++)
			{
				int val=a[x1];
				opt tmp;
				if(s1[tp1]==val)
				{
					tmp.type=1,tmp.x=1;
					ans[++cnt]=tmp;
					tp1--;
				}
				else if()
			}
		}*/
	return 0;
}
