#include<bits/stdc++.h>
using namespace std;
int n,m,k;
int a[310][10000]={0};
int top[310]={0},low[310]={0};
int use[1000][100]={0},used[1000]={0};
int road[2000000][3]={0},op=0;
void check(int t)
{
	for(int i=1;i<n;i++)
	{
		if(i!=t&&a[i][low[i]]==a[t][low[t]])
		{
			op++;
			road[op][0]=2,road[op][1]=i,road[op][2]=t;
			low[i]++;
			low[t]++;
			use[a[i][low[i]]][0]-=2;
			check(i);
			check(t);
		}
	}
	return;
}
int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int t,r=0;
	cin>>t;
	if(t%10!=1)r=1;
	while(t--)
	{
		cin>>n>>m>>k;
		op=0;
		memset(a,0,sizeof(a));
		memset(top,0,sizeof(top));
		memset(low,0,sizeof(low));
		memset(use,0,sizeof(use));
		memset(road,0,sizeof(road));
		for(int j=1;j<=m;j++)
		{
			int x;
			scanf("%d",&x);
			bool flag=0;
			for(int i=1;i<n;i++)
			{
				if(top[i]==low[i])
				{
					op++;
					road[op][0]=1,road[op][1]=i;
					//printf("1 %d\n",i);
					a[i][top[i]++]=x;
					flag=1;
					use[x][++use[x][0]]=i;
					break;
				}
				else if(a[i][top[i]-1]==x)
				{
					op++;
					road[op][0]=1,road[op][1]=i;
					//printf("1 %d\n",i);
					top[i]--;
					flag=1;
					use[x][0]--;
					break;
				}
				else if(a[i][low[i]]==x)
				{
					op++;
					road[op][0]=1,road[op][1]=n;
					op++;
					road[op][0]=2,road[op][1]=i,road[op][2]=n;
					//printf("1 %d\n2 %d %d",n,i,n);
					low[i]++;
					check(i);
					flag=1;
					use[x][0]--;
					break;
				}
			}
			if(flag==0)
			{	
				for(int i=1;i<=use[x][0];i++)
				{
					used[use[x][i]]++;
				}
				int mn=1000,mnt;
				for(int i=n-1;i>=1;i--)
				{
					if(used[i]==0)
					{
						mnt=i;
						break;
					}    
				}
				op++;
				road[op][0]=1,road[op][1]=mnt;
				//printf("1 %d\n",i);
				a[mnt][top[mnt]++]=x;
				use[x][++use[x][0]]=mnt;
			}
		}
		printf("%d\n",op);
		for(int i=1;i<=op;i++)
		{
			if(road[i][0]==1)
			{
				printf("1 %d\n",road[i][1]);
			}
			else
			{
				printf("2 %d %d\n",road[i][1],road[i][2]);
			}
		}
	}
	return 0;
}