#include <bits/stdc++.h>
using namespace std;
int T,n,m,k,q[1005][2],r[1005],x,b[1005];
queue <int> qu;
int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	scanf("%d",&T);
	while (T--)
	{
		scanf("%d%d%d",&n,&m,&k);
		for (int i=1;i<n;++i) qu.push(i);
		for (int i=1;i<=m;++i)
		{
			scanf("%d",&x);
			if (b[x])
			{
				if (q[b[x]][r[b[x]]-1]!=x)
				{
					printf("1 %d\n",n);
					printf("2 %d %d\n",b[x],n);
					q[b[x]][0]=q[b[x]][1];
					r[b[x]]--;
					qu.push(b[x]);
					b[x]=0;
				}
				else{
					printf("1 %d\n",b[x]);
					r[b[x]]--;
					q[b[x]][r[b[x]]]=0;
					qu.push(b[x]);
					b[x]=0;
				}
			}
			else{
				int t=qu.front();
				qu.pop();
				q[t][r[t]]=x;
				r[t]++;
				b[x]=t;
				printf("1 %d\n",t);
				if (r[t]<2) qu.push(t);
			}
		}
	}
	return 0;
}
