#include<bits/stdc++.h>
using namespace std;
int t, n, m, k, a;
int st[310][620], vis[310], co[620];
int main()
{
	freopen("meow.in", "r", stdin);
	freopen("meow.out", "w", stdout);
	cin >> t;
	while(t--)
	{
		int cnt = 0;
		scanf("%d%d%d", &n, &m, &k);
		for(int i = 1; i <= n; i++) vis[i] = i;
		for(int i = 1; i <= m; i++)
		{
			scanf("%d", &a);
			if(cnt <= n - 1)
			{
				if(co[a] != 0 && co[a] < cnt)
					if(st[vis[co[a]]][2] == a) printf("1 %d\n", vis[co[a]]), st[vis[co[a]]][2] = 0;
					else{ printf("2 %d\n2 %d %d\n", vis[cnt], vis[cnt], vis[co[a]]), st[vis[co[a]]][1] = st[vis[co[a]]][2], st[vis[co[a]]][2] = 0; if(!st[vis[co[a]]][1]){ swap(vis[cnt - 1], vis[co[a]]); cnt--;}}
				else if(st[cnt][1]) printf("1 %d\n", vis[cnt]), st[vis[cnt]][2] = a, co[a] = vis[cnt], cnt++;
				else printf("1 %d\n", cnt), st[cnt][1] = a, co[a] = vis[cnt];
			}
			else
			{
				if(co[a] != 0 && co[a] < cnt)
					if(st[vis[co[a]]][2] == a) printf("1 %d\n", vis[co[a]]), st[vis[co[a]]][2] = 0;
					else{ printf("2 %d\n2 %d %d\n", vis[cnt], vis[cnt], vis[co[a]]), st[vis[co[a]]][1] = st[vis[co[a]]][2], st[vis[co[a]]][2] = 0; if(!st[vis[co[a]]][1]){ swap(vis[cnt - 1], vis[co[a]]); cnt--;}}
					else printf("1 %d\n", cnt), st[vis[co[a]]][2] = 0;
			}
		}
	}
	return 0;
}
