#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<cmath>
#include<queue>
#include<map>
#define _rep(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;
template<typename Tp>
inline void Rd(Tp &x){
	int f=1;char ch=getchar();
	x=0;
	while(ch<'0' || ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while('0'<=ch && ch<='9') x=x*10+ch-'0', ch=getchar();
}
const int N=330,M=2e6+10;
int n,m,kind,a[M];
int live[M];//1~n表在前边(深),负数表在后边.
//nxt存放后方的值.
int when[N];
int siz[N];
int v[N][4];
queue<int> q;//存放空的内容.
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int T;Rd(T);
	while(T--){
		while(q.size()) q.pop();
		Rd(n),Rd(m),Rd(kind);
		_rep(i,0,m) live[i]=when[i]=0;
		_rep(i,1,n) siz[i]=0,v[i][1]=v[i][2]=v[i][3]=0;
		int ept=n;
		_rep(i,1,n-1) q.push(i);
		_rep(i,1,m) Rd(a[i]);

		_rep(i,1,m){
			int x=a[i],t=live[x];
			if(t){
				if(t>0 && ept==t){//此时作为最终的栈,不加入queue.
					printf("1 %d\n",ept);
					siz[t]--;
					v[t][1]=v[t][2],v[t][2]=v[t][3],v[t][3]=0;
					live[v[t][1]]= abs(live[v[t][1]]);
					live[v[t][2]]=-abs(live[v[t][2]]);
					continue;
				}
				if(t>0)//深的,删此点,改浅点.
					printf("1 %d\n",ept),
					printf("2 %d %d\n",ept,t),
					siz[t]--,q.push(t),
					v[t][1]=v[t][2],v[t][2]=0,live[v[t][1]]=-live[v[t][1]];
				else//匹配上浅的.
					printf("1 %d\n",-t),
					siz[-t]--,q.push(-t),v[-t][2]=0;

				live[x]=0;
			}
			else{
				while(q.size() && (siz[q.front()]>=2 || q.front()==ept)) q.pop();
				if(q.size()){//仍有空.
					int wei=q.front();
					siz[wei]++;
					printf("1 %d\n",wei);
					if(siz[wei]==2) live[x]=-wei, v[wei][2]=x;
					else live[x]=q.front(), v[wei][1]=x;
					continue;
				}
				//没空了,找第一个深点.
				int j=i+1;
				while(j<=m){
					t=live[a[j]];
//					if(t==0){printf("ERROR!\n");return -1;}
					//t为现在的点的深浅+位置.
					if(when[abs(t)]==i){//之前有个浅层的已访问.
						printf("1 %d\n",ept);
						siz[ept]=1,q.push(ept), v[ept][1]=x;
						ept=abs(t);
						break;
					}
					when[abs(t)]=i;

					if(t>0){//深点.
						printf("1 %d\n",t),
						siz[t]++,v[t][siz[t]]=x,live[x]=-t;
						break;
					}
					//浅点忽略.
					j++;
				}
			}
		}
	}
	return 0;
}

