#include <bits/stdc++.h>
#define int long long
#define ll long long
#define ri register
#define in inline
#define INF 0x3f3f3f3f
using namespace std;
const int N=350;
const int M=2e6+10;
struct Q{
	int opt;
	int fir,sco1,sco2;
}sc[M*2];
int n,m,k;
int a[M],s[N];
int vis[2*N],xb[N];
int found[2*N],lz[2*M];
int tw[2*M];
int ans=0;
in void init(){
	memset(s,0,sizeof(s));
	memset(found,0,sizeof(found));
	memset(lz,0,sizeof(lz));
	memset(xb,0,sizeof(xb));
	memset(vis,0,sizeof(vis));
	memset(sc,0,sizeof(sc));
	ans=0;
}
in void write(){
	cout << ans << "\n";
	for(int i=1;i<=ans;i++){
		cout << sc[i].opt << " ";
		if(sc[i].opt==1){
			cout << sc[i].fir << "\n";
		}else {
			cout << sc[i].sco1 << " " << sc[i].sco2 << "\n";
		}
	}
	return;
}
signed main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int T;
	cin >> T;
	while(T--){
		cin >> n >> m >> k;
		init();
		for(int i=1;i<=m;i++){
			cin >> a[i];
			vis[a[i]]++;
		}
		int w=m;
		if(n==1){
			cout << m << "\n";
			for(int i=1;i<=m;i++) cout << "1 1\n";
		}else if(n==2){
			int gs=0;
			for(int i=1;i<=m;i++){
				if(w==0) break;
				if(a[i]==tw[gs]){
					sc[++ans].opt=1;
					sc[ans].fir=1;
					gs--;
					w-=2;
				}else if(gs<w/2){
					sc[++ans].opt=1;
					sc[ans].fir=1;
					tw[++gs]=a[i];
				}else{
					sc[++ans].opt=1;
					sc[ans].fir=2;
				}
			}
			for(int i=1;i<=w/2;i++){
				sc[++ans].opt=2;
				sc[ans].sco1=1,sc[ans].sco2=2;
			}
			write();
		}else{
			for(int i=1;i<=2*m;i++){
				found[a[i]]++;
				if(xb[1]<w/2&&found[a[i]]<vis[a[i]]/2){
					xb[1]++;
					sc[++ans].opt=1;
					sc[ans].fir=1;
				}else{
					for(int i=2;i<=n;i++){
						int flag=0;
					}
				}
			}
		}
	}
}
/*
1
2 4 2
1 2 1 2
*/