#include<bits/stdc++.h>
using namespace std;
struct node{
	string tu;
	int head;
	int tail;
};
void search(int n,int m,int k)
{
	node num[n+1];
	int a;
	int ans;
	int nu=0;//not empty num
	for(int i=1;i<=m;i++)
	{
		cin>>a;
		for(int j=1;j<=nu;j++)
		{
			if(int(num[j].tu[num[j].tail])==a)
			{
				num[j].tail--;
				ans++;
				cout<<"1 "<<j<<endl;
				break;
			}	
		}
		if(nu<n)
		{
			nu++;
			num[nu].tail++;
			num[nu].tu[num[nu].tail]=char(a);
		for(int j=1;j<=nu;j++)
			if(int(num[j].tu[num[j].head])==a)
			{
				num[j].head++;
				nu--;
				num[nu].tail--;
				ans++;
				cout<<"2 "<<j<<" "<<nu+1<<endl;
			}
		}
	}
}
int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	for(int i=1;i<=t;i++)
	{
		int n,m,k;
		cin>>n>>m>>k;
		search(n,m,k);
	}
}