#include<bits/stdc++.h>
using namespace std;
int nums[2000010];
int stk[310][2];
map<int,int> mp;
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int t; scanf("%d",&t);
	while(t--){
		mp.clear();
		int n,m,k,pre=0;
		scanf("%d%d%d",&n,&m,&k); int emp=m;
		for(int i=1;i<=n;i++) stk[i][1]=0,stk[i][0]=0;
		for(int j=0;j<m;j++) scanf("%d",&nums[j]);
		for(int i=0;i<m;i++){
			if((!mp[nums[i]])&&pre<n){
				pre++;
				for(int j=1;j<=n;j++) if(!stk[j][0]){printf("1 %d\n",j); stk[j][0]=nums[i],mp[nums[i]]=j; break;}
				if(pre==n) for(int j=i+1;j<m;j++) if(mp[nums[j]]){emp=mp[nums[j]]; break;}
			}else if(pre>=n&&(!mp[nums[i]])){
				pre++;
				for(int j=1;j<=n;j++){
					if(j!=emp){
						if(!stk[j][0]){printf("1 %d\n",j); stk[j][0]=nums[i],mp[nums[i]]=j; break;}
						else if(!stk[j][1]){printf("1 %d\n",j); stk[j][1]=nums[i],mp[nums[i]]=j; break;}
					}
				}
			}else if(pre>=n&&mp[nums[i]]){
				if(stk[mp[nums[i]]][1]){
					printf("1 %d\n",emp);
					printf("2 %d %d\n",emp,mp[nums[i]]);
					stk[mp[nums[i]]][0]=stk[mp[nums[i]]][1];
					stk[mp[nums[i]]][1]=0;
					mp[nums[i]]=0;
					pre--;
				}else{
					printf("1 %d\n",mp[nums[i]]);
					stk[mp[nums[i]]][1]=0;
					mp[nums[i]]=0;
					pre--;
				}
			}else if(pre<n&&mp[nums[i]]){
				if(stk[mp[nums[i]]][1]){
					printf("1 %d\n",emp);
					printf("2 %d %d\n",emp,mp[nums[i]]);
					stk[mp[nums[i]]][0]=stk[mp[nums[i]]][1];
					stk[mp[nums[i]]][1]=0;
					mp[nums[i]]=0;
					pre--;
				}else{
					printf("1 %d\n",mp[nums[i]]);
					stk[mp[nums[i]]][0]=0;
					mp[nums[i]]=0;
					pre--;
				}
			}
		}
	}
	return 0;
}

