#include<bits/stdc++.h>
using namespace std;
int T,n,m,k;
struct oper
{
	int tp,s1,s2;
	oper(int x){tp=1;s1=x;}
	oper(int x,int y){tp=2;s1=x;s2=y;}
};
vector<oper> Ops;
void printop()
{
	printf("%d\n",Ops.size());
	for(oper i:Ops)
		if(i.tp==1)printf("1 %d\n",i.s1);
		else printf("2 %d %d\n",i.s1,i.s2);
}
mt19937 rnd(20051029);
namespace Sub1
{
	int st[605],sz[305],attop[605];
	vector<int> avai;
	void solve()
	{
		for(int i=1;i<n;i++)
		{
			avai.emplace_back(i);
			avai.emplace_back(i);
		}
		for(int i=1;i<=m;i++)
		{
			int x;
			scanf("%d",&x);
			if(st[x])
			{
				if(attop[x])
					Ops.emplace_back(st[x]);
				else
				{
					Ops.emplace_back(n);
					Ops.emplace_back(n,st[x]);
				}
				sz[st[x]]--;
				avai.push_back(st[x]);
				st[x]=0;
			}
			else if(avai.size())
			{
				int to=avai.back();avai.pop_back();
				Ops.emplace_back(to);
				st[x]=to;attop[x]=sz[to];
				sz[to]++;
			}
			else
			{
				int to=rnd()%(n-1)+1;
				Ops.emplace_back(to);
				st[x]=to;attop[x]=2;
				sz[to]++;
			}
		}
		printop();
	}
}
int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	for(scanf("%d",&T);T;T--)
	{
		scanf("%d%d%d",&n,&m,&k);
//		if(k<=2*n-2)
//		{
			Sub1::solve();
//			continue;
//		}
		
	}
	return 0;
}