#include <bits/stdc++.h>
#define OK
using namespace std;
int read ()
{
    char ch=getchar();
    int flag=1,x=0;
    while (ch<'0' || ch>'9')
    {
    	if (ch=='-') flag=-flag;
    	ch=getchar();
	}
	while (ch>='0' && ch<='9')
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return flag*x;
}
int T,n,m,k,a[2000005],size[305];
int opt[4000005][3];
deque<int> dq[305];
int search (int u,int cnt)
{
//	if (u%100==0)
//		printf ("search (%d)\n",u);
	if (u>=m+1) return cnt;
	for (int j=1;j<=n;j++)
		if (!dq[j].empty() && dq[j].back()==a[u])
		{
//			printf ("1 %d\n",j);
			opt[cnt+1][0]=1;
			opt[cnt+1][1]=j;
			dq[j].pop_back();
			size[j]--;
			return search (u+1,cnt+1);
		}
	for (int j=1;j<=n;j++)
		if (!dq[j].empty() && dq[j].front()==a[u])
		{
			for (int k=1;k<=n;k++)
				if (dq[k].empty())
				{
//					printf ("1 %d\n",k);
//					printf ("2 %d %d\n",j,k);
					opt[cnt+1][0]=1;
					opt[cnt+1][1]=k;
					opt[cnt+2][0]=2;
					opt[cnt+2][1]=j;
					opt[cnt+2][2]=k;
					dq[j].pop_front();
					size[j]--;
					return search (u+1,cnt+2);
				}
			return 0;
		}
	for (int j=1;j<=n;j++)
		if (size[j]<2)
		{
			if (j>n) return 0;
//			printf ("try 1 %d\n",j);
			opt[cnt+1][0]=1;
			opt[cnt+1][1]=j;
			dq[j].push_back(a[u]);
			size[j]++;
			int t=search(u+1,cnt+1);
			if (t) return t;
			dq[j].pop_back();
			size[j]--;
//			printf ("try 1 %d failed\n",j);
		}
	return 0;
}
int main ()
{
#ifdef OK
	freopen ("meow.in","r",stdin);
	freopen ("meow.out","w",stdout);
#endif
//	srand(time(0)*922*825+1120+421);
	T=read();
	while (T--)
	{
		n=read(); m=read(); k=read();
		for (int i=1;i<=m;i++)
		{
			a[i]=read();
		}
		int cnt=search (1,0);
		printf ("%d\n",cnt);
		for (int i=1;i<=cnt;i++)
		{
			if (opt[i][0]==1)
				printf ("1 %d\n",opt[i][1]);
			else printf ("2 %d %d\n",opt[i][1],opt[i][2]);
		}
	}
#ifndef OK
	printf ("%d\n",clock());
#endif
	return 0;
}
// P.S. 杭师大仓前没有中文输入法
// 所以您猜我是怎么打出这几行字的
//（显然需要自己安装输入法）
/* checker.cpp
#include <bits/stdc++.h>
using namespace std;
int T,n,m,k,a[2000005],t;
deque<int> dq[305];
int main (int argc, char** argv)
{
	FILE* fin=fopen (argv[1],"r");
	FILE* fout=fopen (argv[2],"r");
	fscanf (fin,"%d",&T);
	for (int TT=1;TT<=T;TT++)
	{
		fscanf (fin,"%d%d%d",&n,&m,&k);
		for (int i=1;i<=n;i++)
			fscanf (fin,"%d",a+i);
		int now=1;
		fscanf (fout,"%d",&t);
		for (int tt=1;tt<=t;tt++)
		{
			int opt,x,y;
			fscanf (fout,"%d%d",&opt,&x);
			if (opt==1)
			{
				if (!dq[x].empty() && dq[x].back()==a[now])
					dq[x].pop_back(), now++;
				else dq[x].push_back(a[now++]);
			}
			else
			{
				fscanf (fout,"%d",&y);
				if (dq[x].empty())
				{
					printf ("Wrong Answer: Invalid operation in task %d, step %d: 2 %d %d\n",TT,tt,x,y);
					printf ("Stack %d empty\n",x);
					return 1;
				}
				if (dq[y].empty())
				{
					printf ("Wrong Answer: Invalid operation in task %d, step %d: 2 %d %d\n",TT,tt,x,y);
					printf ("Stack %d empty\n",y);
					return 1;
				}
				if (dq[x].front()!=dq[y].front())
				{
					printf ("Wrong Answer: Invalid operation in task %d, step %d: 2 %d %d\n",TT,tt,x,y);
					printf ("The bottom of stack %d and %d differ\n",x,y);
					return 1;
				}
				dq[x].pop_front();
				dq[y].pop_front();
			}
		}
		for (int i=1;i<=n;i++)
			if (!dq[i].empty())
			{
				printf ("Wrong Answer: Stack %d not empty after task %d\n",i,TT);
				return 1;
			}
	}
	puts ("OK Accepted");
	return 0;
}
*/
