#include<bits/stdc++.h>
using namespace std;
struct reader{
	#define gc ch=getchar()
	template<typename T>
	reader&operator>>(T&x){
		char gc;x=0;int f=1;
		for(;!isdigit(ch);gc)ch=='-'&&(f=-f);
		for(;isdigit(ch);gc)x=x*10+ch-'0';
		x*=f;return*this;
	}
}fin;
const int N=2000006;
int n,m,k,a[N],T;
using pii=pair<int,int>;
//map<int,pii>s;
int s[1003][2];
int s_[1003][2];
int st[1003][2],bt[1003];
priority_queue<pii,vector<pii>,less<pii> >li;
#define x first
#define y second
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
//	freopen("meow2.in","r",stdin);
//	freopen("1.out","w",stdout);
	fin>>T;
	while(T--){
		fin>>n>>m>>k;while(!li.empty())li.pop();
		for(int i=2;i<=n;i++)li.push({2,i}),li.push({1,i});
		for(int i=1;i<=m;i++)fin>>a[i];
		for(int i=1;i<=m;i++){
			if(s[a[i]][0]){
				int o=s[a[i]][1];
				if(s[a[i]][0]==2){
					s_[o][0]=s_[o][1],s_[o][1]=0;
					if(!s_[o][0])li.push({0,o});
					if(!s_[o][1])li.push({1,o});
					s[a[i]][0]=s[a[i]][1]=0;
					printf("2 1 %d\n",o);
				}else{
					s_[o][1]=0;li.push({1,o});
					printf("1 %d\n",o);
				}
			}else{
				while(!li.empty()&&s_[li.top().y][li.top().x])li.pop();
				if(li.empty()){
					int o=a[i+1];
					printf("1 %d\n",s[o][1]);
				}else{
					pii o=li.top();li.pop();
					s[a[i]][0]=o.x;s[a[i]][1]=o.y;
					s_[o.y][2-o.x]=a[i];
					printf("1 %d\n",o.y);
				}
			}
		}
		
	}
}