#include<bits/stdc++.h>
using namespace std;
int T,n,m,k,a[2000005];
struct node{
	int opt,s1,s2;
};
deque<int>q[305],p1,p2;
node ans[10000005];
int cnt;
int flg;
void chk(){
	int tmp=1;
	for(int i=1;i<=n;i++){
		if(!q[i].empty()){
			tmp=0;
			break;
		}
	}
	if(tmp==1){
		flg=1;
		return;
	}
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			if(q[i].empty() || q[j].empty() || q[i].front()!=q[j].front()){
				continue;
			}
			int temp=q[i].front();
			q[i].pop_front();
			q[j].pop_front();
			cnt++;
			ans[cnt].opt=2;
			ans[cnt].s1=i;
			ans[cnt].s2=j;
			chk();
			q[i].push_front(temp);
			q[j].push_front(temp);
			if(flg==1){
				return;
			}
			cnt--;
		}
	}
}
void search(int x){
	if(x>m){
		chk();
		return;
	}
	cnt++;
	ans[cnt].opt=1;
	for(int i=1;i<=n;i++){
		ans[cnt].s1=i;
		if(q[i].empty()){
			q[i].push_back(a[x]);
			search(x+1);
			q[i].pop_back();
		}
		else if(q[i].back()!=a[x]){
			q[i].push_back(a[x]);
			search(x+1);
			q[i].pop_back();
		}
		else{
			q[i].pop_back();
			search(x+1);
			q[i].push_back(a[x]);
		}
		if(flg){
			return;
		}
	}
	cnt--;
}
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<=n;i++){
			q[i].clear();
		}
		for(int i=1;i<=m;i++){
			scanf("%d",&a[i]);
		}
		cnt=0;
		flg=0;
		search(1);
		printf("%d\n",cnt);
		for(int i=1;i<=cnt;i++){
			if(ans[i].opt==1){
				printf("%d %d\n",ans[i].opt,ans[i].s1);
			}
			else{
				printf("%d %d %d\n",ans[i].opt,ans[i].s1,ans[i].s2);
			}
		}
	}
	return 0;
}

