#include<bits/stdc++.h>
using namespace std;

int T;
int op;
long long n,m,k;
int head;
int s[20061219];
int a[20000][20000];
int len[20061219];
bool vis[20061219];

struct cao_zuo{
	int c,z1,z2;
};
queue<cao_zuo>Q;

inline void doit(){
	cin>>n>>m>>k;              
	for(int i=1;i<=m;i++){
		cin>>s[i];
	}
	
	
	for(int x=1;x<=m;x++){
		bool flag=1; //un did
		for(int i=1;i<=n;i++){
			if(len[i]==0){
				a[i][++len[i]]=s[x];
				Q.push((cao_zuo){1,i,0});
				op++;
				flag=0;
				break;
			}
			else if(a[i][len[i]-1]==s[x]){
				Q.push((cao_zuo){1,i,0});
				a[i][len[i]--]=0;
				flag=0;
				op++;
				break;
			}
		}
		if(flag){
			a[1][++len[1]]=s[x];
			Q.push((cao_zuo){1,1,0});
			op++;
		}
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				if(!len[i]||!len[j])continue;
				if(a[i][1]==a[j][1]){
					Q.push((cao_zuo){2,i,j});
					op++;
					for(int k=1;k<len[i];k++){
						a[i][k]=a[i][k+1];
					}
					for(int k=1;k<len[j];k++){
						a[j][k]=a[j][k+1];
					}
					len[i]--,len[j]--;
				}
			}
		}
	}
	cout<<op<<endl;
	while(!Q.empty()){
		cout<<Q.front().c<<" "<<Q.front().z1;
		if(Q.front().z2!=0)cout<<" "<<Q.front().z2;
		cout<<endl;
		Q.pop();
	}
}

int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	cin>>T;
	for(int i=1;i<=T;i++){
		op=0;
		memset(s,0,sizeof(s));
		memset(a,0,sizeof(a));
		memset(len,0,sizeof(len));
		memset(vis,0,sizeof(vis));
		doit();
	}
	return 0;
}