#include<bits/stdc++.h>
#define N 2000005
#define M 305
#define pb(x) push_back(x)
using namespace std;
int T,n,m,k,a[N],l[M],r[M],t;
vector<int>v[M];
inline int read(){
	int res=0;char ch=getchar();int f=ch=='-'?-1:1;
	while(ch<'0'||ch>'9')ch=getchar(),f=ch=='-'?-1:f;
	while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
	return res*f;
}
bool tmp;
struct p{
	int op,x,y;
}q[N>>1];
inline bool check(){
	for(int i=1;i<=m;++i)if(l[i]<=r[i])return 0;
	return 1;
}
inline void print(){
	printf("%d\n",t);
	for(int i=1;i<=t;++i)
	if(q[i].op==1)printf("%d %d\n",q[i].op,q[i].x);
	else printf("%d %d %d\n",q[i].op,q[i].x,q[i].y);
}
inline void add(int x,int y){
	++r[x];
	if(r[x]+1>v[x].size())v[x].pb(y);
	else v[x][r[x]]=y;
}
inline void dfs(int x){
	if(x==n+1){if(check())tmp=1,print();return;}
	if(tmp)return;
	int th=0;
	for(int i=1;i<=m;++i){
		if(l[i]>r[i])continue;
		if(v[i][r[i]]==a[x]){
			q[++t].op=1,q[t].x=i;
			--r[i];dfs(x+1);return;
		}
		if(v[i][l[i]]==a[x])th=i;
	}
	if(th)for(int i=1;i<=m;++i)if(l[i]>r[i]){
		q[++t].op=1,q[t].x=i;
		q[++t].op=2,q[t].x=i,q[t].y=th;
		++l[th];dfs(x+1);return;
	}
	for(int i=1;i<=m;++i)if(r[i]-l[i]+1<(n/2)){
		q[++t].op=1,q[t].x=i;
		add(i,a[x]);dfs(x+1);
		--r[i],--t;
	}
}
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	T=read();
	while(T--){
		m=read(),n=read(),k=read();
		for(int i=1;i<=n;++i)a[i]=read();
		tmp=0;for(int i=1;i<=m;++i)v[i].clear(),l[i]=0,r[i]=-1;
		dfs(1);
	}
	return 0;
}
