#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int M=1e8+2;
int T,n,k,a[1002],b[302][302],ed[302],top[302],to,num,side=1;
bool u;
struct as{
	int t,t1,t2;
}ans[M];
bitset<302> bt,bp;
ll m;
void inti(){
	cin>>n>>m>>k;
	num=m;
	memset(b,0,sizeof(n));
	memset(a,0,sizeof(a));
	bt=bp;
	u=1;
}
void update2(int t,int i,int j){
	ed[i]++;ed[j]++;
	ans[++to].t=t;
	ans[to].t1=i;
	ans[to].t2=j;
	u=0;
}
void update1(int t,int i){
	top[i]--;
	top[0]--;
	ans[++to].t=t;
	ans[to].t1=i;
	u=0;
}
void check2(){
	for(int i=0;i<=n;i++){
		if(bt[i]){
			bt[i]=0;
			for(int j=0;j<=n&&j!=i;j++){
				if(ed[i]==ed[j]) update2(2,i,j);
			}
		}
	}
}
void check1(){
	for(int i=1;i<=n;i++){
		if(top[0]==top[i]){
			update1(1,i);
		}
	}
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	bp[0]=1;
	cin>>T;
	while(T--){
		inti();
		for(int i=1;i<=m;i++) cin>>a[++top[0]];
		while(top[0]!=ed[0]){
			u=1;
			check2();
			check1();
			if(u){
				u=0;
				if(side>n) side=1;
				update1(1,side);
				bt[side]=1;
			}
		}
		cout<<to<<endl;
		while(to--){
			if(ans[to].t==1){
				cout<<1<<" "<<ans[to].t1<<endl;
			}
			else cout<<2<<" "<<ans[to].t1<<" "<<ans[to].t2<<endl;
		}
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}