#include <bits/stdc++.h>
using namespace std;
struct node{
	int tp, x, y;
}op[200005];
bool flag = 0;
int sta[305][200005], head[305], tail[305], cnt, n, m, k, a[200005];//No MLE plz...
void print ()
{
	printf ("%d\n", cnt);
	for (int i = 1; i <= cnt; i++)
		if (op[i].tp == 1)
			printf ("1 %d\n", op[i].x);
		else
			printf ("2 %d %d\n", op[i].x, op[i].y);
}
bool check ()
{
	for (int i = 1; i <= n; i++)
		if (head[i] != tail[i])
			return 0;
	return 1;
}
void search(int x, int step)
{
	if (flag)
		return;
	if (step > 1000)//God bless
		return;
	if (x == m + 1)
	{
		if (check())
		{
			flag = 1;
			print ();
		}
		return;
	}
	for (int i = 1; i <= n; i++)
	{
		bool f = 0;
		sta[i][++tail[i]] = a[x];
		if (sta[i][tail[i]] == sta[i][tail[i] - 1])
			f = 1, tail[i] -= 2;
		op[++cnt] = (node){1, i, 0};
		search (x + 1, step + 1);
		cnt--;
		if (f)
			sta[i][++tail[i]] = a[x];
		else
			tail[i]--;
		if (flag)
			return;
	}
	for (int i = 1; i < n; i++)
		for (int j = i + 1; j <= n; j++)
			if (sta[i][head[i]] == sta[j][head[j]] && tail[i] >= head[i] && tail[j] >= head[j])
			{
				head[i]++;
				head[j]++;
				op[++cnt] = (node){2, i, j};
				search (x, step + 1);
				if (flag)
					return;
				cnt--;
				head[i]--;
				head[j]--;
			}
}
int main ()
{
	freopen ("meow.in", "r", stdin);
	freopen ("meow.out", "w", stdout);
	
	int T;
	scanf ("%d", &T);
	while (T--)
	{
		flag = 0;
		memset (sta, 0, sizeof (sta));
		for (int i = 1; i <= n; i++)
			head[i] = 1;
		memset (tail, 0, sizeof (tail));
		cnt = 0;
		scanf ("%d%d%d", &n, &m, &k);
		for (int i = 1; i <= m; i++)
			scanf ("%d", &a[i]);
		search (1, 1);
	}// I can't find a better way nya~
	
	return 0;
}

