#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool read_(T &ready_get)
{
	T x=0,f=1;
	char ch=getchar();
	while(!('0'<=ch&&ch<='9'))
	{
		if(ch=='-') f=-1;
		if(ch==-1) return false;
		ch=getchar();
	}
	while('0'<=ch&&ch<='9')
	{
		x=x*10+(ch-'0');
		ch=getchar();
	}
	ready_get=f*x;
	return true;
}
struct Ans{
	int ope,x,y;
} ans[4000007];
int n,m,k,a[2000007],c[2000007],cnt;
deque <int> s[307];
namespace solve1
{
	bool bomb()
	{
		for(int i=1;i<=n;++i)
		{
			if(s[i].empty()) continue;
			for(int j=i+1;j<=n;++j)
			{
				if(s[j].empty()) continue;
				if(s[i].front()==s[j].front())
				{
					s[i].pop_front(),s[j].pop_front();
					ans[cnt++]={2,i,j};
					return true;
				}
			}
		}
		return false;
	}
	bool judge()
	{
		for(int i=1;i<=n;++i)
		{
			while(!s[i].empty()) s[i].pop_front();
		}
		for(int i=1;i<=m;++i)
		{
			if(!s[c[i]].empty()&&s[c[i]].back()==a[i]) s[c[i]].pop_back();
			else s[c[i]].push_back(a[i]);
			ans[cnt++]={1,c[i]};
			while(bomb());
		}
		for(int i=1;i<=n;++i)
		{
			if(!s[i].empty()) return false;
		}
		return true;
	}
	void print()
	{
		printf("%d\n",cnt);
		for(int i=0;i<cnt;++i)
		{
			printf("%d ",ans[i].ope);
			if(ans[i].ope==1) printf("%d\n",ans[i].x);
			else printf("%d %d\n",ans[i].x,ans[i].y);
		}
	}
	void dfs(int t)
	{
		if(t>m)
		{
			cnt=0;
			if(judge()) print(),exit(0);
			return;
		}
		for(int i=1;i<=n;++i)
		{
			c[t]=i;
			dfs(t+1);
		}
	}
	void main()
	{
		dfs(1);
	}
}
int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int T;
	read_(T);
	while(T--)
	{
		read_(n),read_(m),read_(k);
		for(int i=1;i<=m;++i)
			read_(a[i]);
		solve1::main();
	}
	return 0;
}