#include<bits/stdc++.h>
using namespace std;
int read(){
	int res=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=-f;ch=getchar();}
	while(isdigit(ch)) {res=res*10+(ch-'0');ch=getchar();}
	return res*f;
}
const int maxn=2e6;
int a[maxn];
int v[maxn];
int pos[maxn];
int n,m,K,tot;
vector<pair<int,int> >ans;
//10:45
//12:00
signed main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int T=read();
	while(T--){
		n=read(),m=read(),K=read();tot=0;
		int w=1;//zhuangtai
		for(int i=1;i<=m;i++) a[i]=read();
		int cnt=0;
		int siz=n-1;
		//if(K==2*n-2) {
			for(int i=1;i<=m;i++) {
				if(!v[a[i]]) {
					if(siz) v[a[i]]=1,pos[a[i]]=(++cnt)%(n-1)+1,siz--;
					else v[a[i]]=2,pos[a[i]]=(++cnt)%(n-1)+1;
					ans.push_back({cnt%n+1,0});
				}
				else if(v[a[i]]) {
					if(v[a[i]]==1){ ans.push_back({n,0});
						if(pos[a[i]]!=n) ans.push_back({n,pos[a[i]]});
					}
					else ans.push_back({pos[a[i]],0});
					v[a[i]]=0;pos[a[i]]=0;
				}
			}
			for(pair<int,int> x: ans){
				if(x.second==0) cout<<1<<" "<<x.first<<"\n";
				else cout<<2<<" "<<x.first<<" "<<x.second<<"\n";
			}
		//}
	}
	return 0;
}   
   