#include<bits/stdc++.h>
#define up(i,x,y) for (int (i)=(x);(i)<=(y);(i)++)
#define down(i,x,y) for (int (i)=(x);(i)>=(y);(i)--)
#define ll long long
#define elif else if
using namespace std;
int read(){
	int x=0;
	char c=getchar();
	bool f=0;
	while (c<'0' or c>'9') {
		if (c=='-') f=1;
		c=getchar();
	}
	while (c>='0' and c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	return (f?-x:x);
}
int n,m,K,a[200005],op[400005][3],opi;
vector<int>v[305];

bool dfs(int i){
	if (opi>2*m) return 0;
	if (i>m){
		up(j,1,n)
			if (int(v[j].size())) return 0;
		printf("%d\n",opi);
		up(j,1,opi){
			if (op[j][0]==1) printf("1 %d\n",op[j][1]);
			else printf("2 %d %d\n",op[j][1],op[j][2]);
		}
		return 1;
	}
	opi++;
	up(j,1,n) up(k,1,n){
		if (v[j].size() and v[k].size() and v[j][0]==v[k][0] and j!=k){
			op[opi][0]=2,op[opi][1]=j,op[opi][2]=k;
			int tmp=v[j][0];
			v[j].erase(v[j].begin());
			v[k].erase(v[k].begin());
			if (dfs(i)) return 1;
			v[j].insert(v[j].begin(),tmp);
			v[k].insert(v[k].begin(),tmp);
		}
	}
	op[opi][0]=1;
	up(j,1,n){
		op[opi][1]=j;
		if (v[j].size()==0 or v[j][int(v[j].size()-1)]!=a[i]) {
			v[j].push_back(a[i]);
			if (dfs(i+1)) return 1;
			v[j].erase(v[j].end()-1);
		}
		else{
			v[j].erase(v[j].end()-1);
			if (dfs(i+1)) return 1;
			v[j].push_back(a[i]);
		}
	}
	opi--;
	return 0;
}

void solve(){
	opi=0;
	n=read(),m=read(),K=read();
	up(i,1,n) v[i].clear();
	up(i,1,m)
		a[i]=read();
	dfs(1);
}
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int t;
	t=read();
	while (t--) solve();
	fclose(stdin);
	fclose(stdout);
}