#include<bits/stdc++.h>
using namespace std;
const int M = 2e6+5;
int n, m, k;
int a[M];
deque<int> q[305];
bool check()
{
	for(int i=1;i<=n;i++)
		if(!q[i].empty())
			return true;
	return false;
}
string ans="";
int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int T;
	scanf("%d", &T);
	while(T--)
	{
		ans = "";
		scanf("%d%d%d", &n, &m, &k);
		for(int i=1;i<=m;i++)
			scanf("%d", &a[i]);
		int pos = 1, op=0;
		q[1].push_front(a[pos]);
		pos++;
		while(check() || pos==1)
		{
			if(pos>m)
				break;
			/// op 1
			for(int i=1;i<=n;i++)
			{
				if(q[i].empty()) continue;
				int ta = q[i].front();	
				if(a[pos]==ta)
				{
					ans += '1'+' '+(char)(i+'0')+'\n';
					q[i].pop_front();
					pos++;
					i = 1;
					op++;
				}
			}
			int flag = 0;
			for(int i=1;i<=n;i++)
			{
				if(q[i].empty()) continue;
				int tb = q[i].back();
				if(a[pos]==tb)
				{
					for(int j=1;j<=n;j++)
					{
						if(q[j].empty())
						{
							ans += '2'+' '+(char)(i+'0')+' '+(char)(j+'0')+'\n';
							q[i].pop_back();
							op++;
							break;
						}
					}
					pos++;
					i = 1;
				}
			}
			//op 2
			for(int i=1;i<=n;i++)
			{
				if(q[i].empty()) continue;
				int ti = q[i].back();
				for(int j=i+1;j<=n;j++)
				{
					int tj = q[j].back();
					if(ti==tj)
					{
						q[i].pop_back();
						q[j].pop_back();
						ans += '2'+' '+(char)(i+'0')+' '+(char)(j+'0')+'\n';
						op++;
						i = 1;
					}
				}
			}		
		//	cout<<pos<<"\n";
		}
		printf("%d\n", op);
		cout<<ans;
	}
	return 0;
}
