#include<bits/stdc++.h>
using namespace std;
int T,n,k,m;
int tp[2000005],dp[2000005],x;
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<=m;i++){
			scanf("%d",&x);
			bool used=0;
			for(int i=1;i<n;i++){
				if(x==tp[i]){
					tp[i]=0;
					printf("1 %d\n",i);
					used=1;
					break;
				}
				if(x==dp[i]){
					dp[i]=tp[i];
					tp[i]=0;
					printf("1 %d\n",n);
					printf("2 %d %d\n",i,n);
					used=1;
					break;
				}
			}
			if(!used){
				for(int i=1;i<n;i++){
					if(dp[i]==0){
						dp[i]=x;
						printf("1 %d\n",i);
						break;
					}
					if(tp[i]==0){
						tp[i]=x;
						printf("1 %d\n",i);
						break;
					}
				}
			}
			
		}
	}
}