#include<bits/stdc++.h>
#define N 2000005
using namespace std;
int n,m,k,a[N];
int op[N<<1],s1[N<<1],s2[N<<1];
vector<int> v[305];
void print(int x)
{
	printf("%d\n",x-1);
	for(int i=1;i<=x-1;i++)
	{
		printf("%d ",op[i]);
		if(op[i]==1) printf("%d\n",s1[i]);
		else printf("%d %d\n",s1[i],s2[i]);
	}
}
bool OK;
int st[305];
void dfs(int x,int now)
{
	if(x-1+(m-now)>m*2) return ;
	if(now==m+1)
	{
		for(int i=1;i<=n;i++) if(st[i]<v[i].size()) return ;
		print(x),OK=1;
		return ;
	}
	if(OK) return ;
	for(int i=1;i<=n;i++)
	{
		if(st[i]>=v[i].size()) continue;
		for(int j=i+1;j<=n;j++)
		{
			if(st[j]>=v[j].size()) continue;
			if(v[i][st[i]]==v[j][st[j]])
			{
				op[x]=2,s1[x]=i,s2[x]=j,st[i]++,st[j]++;
				dfs(x+1,now);
				st[i]--,st[j]--;
				return ;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		op[x]=1,s1[x]=i;
		v[i].push_back(a[now]);
		int siz=v[i].size();
		if(siz-st[i]>=2&&v[i][siz-1]==v[i][siz-2])
		{
			int tmp=v[i][siz-2];
			v[i].pop_back(),v[i].pop_back();
			dfs(x+1,now+1);
			v[i].push_back(tmp);
		}
		else
		{
			dfs(x+1,now+1);
			v[i].pop_back();
		}
		if(OK) return ;
	}
}
int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int T;
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d%d%d",&n,&m,&k);
		for(int i=1;i<=m;i++) scanf("%d",&a[i]);
		OK=0,dfs(1,1);
		for(int i=1;i<=n;i++) v[i].clear(),st[i]=0;
	}
	return 0;
}