#include<bits/stdc++.h>
using namespace std;
struct stacks{
	int stks[700];
	int l,r;
}stk[400];
int tail[700][400];
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int T;
	scanf("%d",&T);
	while(T--){
		int n,m,k;
		scanf("%d%d%d",&n,&m,&k);
		for(int i=1;i<=n;i++) stk[i].r=-1;
		while(m--){
			int a;
			int flag=0;
			int flag1=0;
			int type=0,target=0;
			int targ1,targ2;
			scanf("%d",&a);
			
			for(int i=1;i<=n;i++){
				if(stk[i].l>stk[i].r) continue;
				if(stk[i].stks[stk[i].r]==a){
					stk[i].r--;
					flag=1;
					type=1;
					target=i;
					break;
				}
			}
			int len=1e9;
			if(flag==0){
				for(int i=1;i<=n;i++)
					len=min(len,(stk[i].r-stk[i].l+1));
				
				for(int i=1;i<=n;i++)
					if(stk[i].r-stk[i].l+1==len){
						stk[i].stks[++stk[i].r]=a;
						type=1;
						target=i;
						break;
					}
					
			}
			if(type==1)
			cout<<type,putchar(' '),cout<<target,putchar('\n');
			for(int i=1;i<=700;i++){
					for(int j=1;j<=n;j++)
						for(int k=1;k<=n;k++){
							if(j==k) continue;
							if(stk[j].stks[stk[j].l]==stk[k].stks[stk[k].l]){
								cout<<2,putchar(' '),cout<<j,putchar(' '),cout<<k,putchar('\n');
								stk[j].l++;
								stk[k].l++;
							}
						}
				}
			}
		}
		return 0;
	}
