#include<bits/stdc++.h>
//#define int long long
#define rint register int
#define UF(i,x,y) for(rint i=x;i<=y;i++)
#define DF(i,x,y) for(rint i=x;i>=y;i--)
#define ce continue
#define inf 0x7fffffff
#define sf scanf
#define pf printf
#define M 20005
using namespace std;
int T,ans[M][3],st[305][M],a[M],n,m,k,op;
bool flag;
inline void work()
{
	memset(ans,0,sizeof(ans));
	memset(st,0,sizeof(st));
	sf("%d%d%d",&n,&m,&k);
	UF(i,1,m) sf("%d",&a[i]);
	op=0;
	int i=1;
	while(i<=m)
	{
		op++;
		flag=0;
		UF(j,1,n) if(st[j][0])
		{
			if(st[j][st[j][0]]==a[i])
			{
				ans[op][0]=1;
				ans[op][1]=j;
				st[j][0]--;
				flag=1;
				i++;
				break;
			}
		}//way 1 delete
		if(!flag)
		{
			UF(j,1,n) if(!st[j][0])
			{
				flag=1;
				ans[op][0]=1;
				ans[op][1]=j;
				st[j][0]++;
				st[j][st[j][0]]=a[i];
				i++;
				break;
			}//way 1 no delete
			if(!flag)
			{
				UF(k,1,n) if(st[k][0])
				UF(j,1,m) if(st[j][0])
				{
					if(st[k][1]==st[j][1])
					{
						ans[op][0]=2;
						ans[op][1]=k;
						ans[op][2]=j;
						UF(l,1,st[k][0]-1)
						st[k][l]=st[k][l+1];
						UF(l,1,st[j][0]-1)
						st[j][l]=st[j][l+1];
						st[j][0]--; st[k][0]--;
						flag=1;
						break;
					}
				}
				if(!flag)
				{
					st[1][0]++;
					st[1][st[1][0]]=a[i];
					i++;
					ans[op][0]=1;
					ans[op][1]=1;
				}
			}//way 2
		}
	}
	pf("%d\n",op);
	UF(i,1,op)
	{
		if(ans[i][0]==1) pf("1 %d\n",ans[i][1]);
		else pf("2 %d %d\n",ans[i][1],ans[i][2]);
	}
}
signed main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	sf("%d",&T);
	while(T--) work();
	fclose(stdin);fclose(stdout);
	return 0;
}