#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int ar[2000005], bc[305], tim[2000005];
bool flag[2000005], flag0[2000005];
int st0[2000005], st1[2000005], st2[2000005], st[305][2], sum[2000005];
int fw[2000005];
int pos0 = 0, pos1 = 0, pos2 = 0, op = 0, t0 = 0;
struct answer
{
	int opt, a, b;
} as[4000005];
void init(int n)
{
	for(int i = 1; i <= n; i++)
		fw[i] = ar[i] = tim[i] = flag[i] = flag0[i] = 0;
	for(int i = 1; i <= max(300, n); i++)
		st0[i] = st1[i] = st2[i];
	for(int i = 1; i <= 300; i++) st[i][0] = st[i][1] = 0;
	pos0 = pos1 = pos2 = op = 0;
}
void add(int n)
{
	t0++;
	while(pos0 && st[st0[pos0]][0]) pos0--;
	if(pos0)
	{
		op++, as[op].opt = 1, as[op].a = st0[pos0];
		bc[n] = -st0[pos0];
		st[st0[pos0]][0] = n;
		st1[++pos1] = st0[pos0];
		pos0--;
		return;
	}
	while(pos1 && (st[st1[pos1]][1] || !st[st1[pos1]][0])) pos1--;
	//if(!pos1) exit(114514);
	op++, as[op].opt = 1, as[op].a = st1[pos1];
	bc[n] = st1[pos1];
	st[st1[pos1]][1] = n;
	st2[++pos2] = st1[pos1];
	pos1--;
}
void del(int sum, int n)
{
	t0--;
	if(bc[n] > 0)
	{
		op++, as[op].opt = 1, as[op].a = bc[n];
		st1[++pos1] = bc[n];
		st[bc[n]][1] = 0;
		bc[n] = 0;
	}
	else
	{
		op++, as[op].opt = 1, as[op].a = sum;
		op++, as[op].opt = 2, as[op].a = -bc[n], as[op].b = sum;
		if(st[-bc[n]][0] && st[-bc[n]][1]) st1[++pos1] = -bc[n];
		else st0[++pos0] = -bc[n];
		bc[st[-bc[n]][1]] *= -1;
		st[-bc[n]][0] = st[-bc[n]][1], st[-bc[n]][1] = 0;
		bc[n] = 0;
	}
}
void fwadd(int n, int p, int t)
{
	while(p <= n) fw[p] += t, p += p & -p;
}
int fwget(int p)
{
	int res = 0;
	while(p) res += fw[p], p -= p & -p;
	return res;
}
int main()
{
	freopen("meow.in", "r", stdin);
	freopen("meow.out", "w", stdout);
	int t, n, m, k, mint = 1e9, t1 = 0;
	scanf("%d", &t);
	while(t--)
	{
		scanf("%d%d%d", &n, &m, &k);
		init(m), mint = 1e9, t0 = 0;
		for(int i = 1; i <= m; i++) scanf("%d", &ar[i]);
		for(int i = 1; i <= m; i++)
		{
			if(!bc[ar[i]]) flag0[i] = 1, bc[ar[i]] = i;
			else if(fwget(bc[ar[i]]) == 0)
			{
				fwadd(m, bc[ar[i]], 1);
				fwadd(m, i + 1, -1);
				flag[i] = flag[bc[ar[i]]] = 1;
				bc[ar[i]] = 0;
			}
			else
			{
				fwadd(m, 1, 1);
				fwadd(m, i + 1, -1);
				bc[ar[i]] = 0;
			}
		}
		//for(int i = 1; i <= m; i++) printf("%d ", flag[i]);
		for(int i = 1; i < n; i++) st0[++pos0] = i;
		for(int i = 1; i <= m; i++)
		{
			if(flag[i])
				op++, as[op].opt = 1, as[op].a = n;
			else if(flag0[i])
				add(ar[i]);
			else del(n, ar[i]);
			//printf("114514\n"), fflush(stdout);
		}
		printf("%d\n", op);
		for(int i = 1; i <= op; i++)
		{
			if(as[i].opt == 1) printf("1 %d\n", as[i].a);
			else printf("2 %d %d\n", as[i].a, as[i].b);
		}
		fflush(stdout);
	}
	return 0;
}
