#include<bits/stdc++.h>
using namespace std;
int T,n,m,k,awa;
int card[2000006];
vector<int>loca[600];
int miao[305][200000];
int head[600],tail[600];
void pushmiao(int locl,int st){
	cout<<1<<' '<<st<<'\n';
	if(card[miao[st][tail[st]]]==card[locl])tail[st]=(tail[st]+200000-1)%200000;
	else card[miao[st][++tail[st]]]=locl;
}
void pullmiao(int st1,int st2){
	cout<<2<<' '<<st1<<' '<<st2<<'\n';
	head[st1]=(head[st1]+1)%200000;
	head[st2]=(head[st2]+1)%200000;
}
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	cin>>T;
	memset(head,0,sizeof(head));
	while(T--){
		cin>>n>>m>>k;
		for(int i=1;i<=m;i++){
			cin>>card[i];
			loca[card[i]].push_back(i);
		}
		pushmiao(1,1);
		for(int i=2;i<=m;i++){
			for(int j=1;j<=n;j++){
				if(card[miao[j][head[j]]]==card[i]){
					if(n-1!=j){
						pushmiao(i,n-1);
						pullmiao(j,n-1);
					}
					else {
						pushmiao(i,n);
						pullmiao(j,n);
					}
				}
				else if(head[j]==tail[j]){
					pushmiao(i,j);
				}
			}
		}
	}
}




























//zhe duan dai ma shi zai shi tai nb le,dao zhi xie zhe duan dai ma de re dou kan bu chu lai ta shi zai gan ma de.