#include<bits/stdc++.h>
using namespace std;

int T,n,m,k,tot,crd[4000005],op,inscol,ins[4000005];

deque<int>q[305];

struct node
{
	int op,st1,st2;
	node(){}
	node(int A,int B,int C):op(A),st1(B),st2(C){}
}ops[4000005];

int read()
{
	int res=0;
	char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
	{
		res=(res<<3)+(res<<1)+(c^48);
		c=getchar();
	}
	return res;
}

void init()
{
	tot=0;
	memset(ins,0,sizeof(ins));
	op=0;
	inscol=0;
}

void in(int k)
{
	int stk=0;
	for(int i=1;i<n;i++)
		if(q[i].size()<2)
			stk=i;
	ops[++op]=node(1,stk,0);
	q[stk].push_back(k);
	ins[crd[k]]=stk;
	inscol++;
}

void op1(int st)
{
	ops[++op]=node(1,st,0);
	q[st].pop_back();
	inscol--;
	tot-=2;
}

void op2(int st1,int st2)
{
	ops[++op]=node(1,st2,0);
	ops[++op]=node(2,st1,st2);
	q[st1].pop_front();
	inscol--;
	tot-=2;
}

void print()
{
	printf("%d\n",op);
	for(int i=1;i<=op;i++)
	{
		if(ops[i].op==1)
			printf("1 %d\n",ops[i].st1);
		else
			printf("2 %d %d\n",ops[i].st1,ops[i].st2);
	}
}

void subtask1()
{
	while(T--)
	{
		init();
		n=read();
		m=read();
		k=read();
		for(int i=1;i<=m;i++)
		{
			crd[i]=read();
			tot++;
		}
		for(int i=1;i<=m && tot;i++)
		{	
			if(!ins[crd[i]])
				in(i);
			else
			{
				if(crd[i]==crd[q[ins[crd[i]]].back()])
					op1(ins[crd[i]]);
				else
					op2(ins[crd[i]],n);
			}
		}
		print();
	}
}

int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	T=read();
	subtask1();
}
//'ve figured out how to solve the rest of the problem but iv got no time left.fuck.
//t3 & t4 are just 2 hard 4 me.
//could've get a 200 but theres no second chance.
//sad.
//whk is an inferno.

//It's not my time.