#include<bits/stdc++.h>
#define rint register int
#define ll long long
#define N 200005
int T,op,n,m,k;
int a[305][N];
int b[N*40][3];
int l[305],r[305];
int wzh[1005];
int zqq[1005][300];
int ans;
int zy;
using namespace std;
//queue<pair<int,int> > q;
//pair<int,int> qwq;
bool check()
{
	bool ymj=false;
	for (rint i=1;i<=2*n-1;i++)
		wzh[i]=0;
	for (rint i=1;i<=n;i++)
	if (l[i]<=r[i])
	{
		wzh[a[i][l[i]]]++;
		zqq[a[i][l[i]]][wzh[a[i][l[i]]]]=i;
		if (wzh[a[i][l[i]]]==2)
		{
			ymj=true;
			wzh[a[i][l[i]]]=0;
			l[zqq[a[i][l[i]]][1]]++;
			ans++;
			b[ans][0]=2;
			b[ans][1]=zqq[a[i][l[i]]][1];
			b[ans][2]=zqq[a[i][l[i]]][2];
			l[i]++;
		}
	}
	return ymj;
}
int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	scanf("%d",&T);
	int x;
	bool p;
	while (T--)
	{
		ans=0;
		scanf("%d%d%d",&n,&m,&k);
		for (rint i=1;i<=n;i++)
			l[i]=1,r[i]=0;
		for (rint i=1;i<=m;i++)
		{
			scanf("%d",&x);
			p=false;
			for (rint j=1;j<=n;j++)
			if (l[j]<=r[j])
			{
				if (a[j][r[j]]==x){
					r[j]--;
//					qwq=make_pair(j,a[j][r[j]]);
//					if (l[j]==r[j]) q.push(qwq);
					ans++;
					b[ans][0]=1;
					b[ans][1]=j;
					p=true;
					break;
				}
			}
			if (!p)
			{
				for (rint j=1;j<=n;j++)
//				if (l[j]<=r[j])
				{
					if (a[j][r[j]]<x)
					{
						r[j]++;
						a[j][r[j]]=x;
//						qwq=make_pair(j,a[j][r[j]]);
//						if (l[j]==r[j]) q.push(qwq);
						ans++;
						b[ans][0]=1;
						b[ans][1]=j;
						p=true;
						break;
					}
				}
			}
			while (check());
		}
		printf("%d\n",ans);
		for (rint i=1;i<=ans;i++)
		{
			if (b[i][0]==1) printf("%d %d\n",b[i][0],b[i][1]);
			else printf("%d %d %d\n",b[i][0],b[i][1],b[i][2]);
		}
	}
	fclose(stdin);fclose(stdout);
	return 0;
}