#include<bits/stdc++.h>
#define int long long
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define foR(i,a,b) for(int i=(a);i>=(b);i--)
#define inf 0x3f3f3f3f
#define pii pair<int,int>
using namespace std;
const int N=305,M=2e6+5;
int a[M];
int T,n,m,k;
int pos[1005];

bool flag=false;
pii op[M];
int tot=0;
deque<int> Q[N];
inline void dfs(int step,int res) {	
	if(step==n+1) {
		if(res) return;
		For(i,1,tot) {
			if(op[i].first==-1) {
				printf("1 %lld",op[i].second);
			} else printf("2 %lld %lld",op[i].first,op[i].second);
		}
		flag=true;
		return;
	}
	if(flag) return;
	int r=res;
	deque<int> Qt;
	For(i,1,3) {
		Qt=Q[i];
		if(Q[i].size()&&Q[i].front()==a[step]) {
			r-=2;
			Q[i].pop_front();
		} else Q[i].push_front(a[step]);
		op[++tot]=make_pair(-1,i);
		For(j,1,3) For(k,1,3)
			if(Q[j].size()&&Q[k].size()&&j!=k&&Q[j].back()==Q[k].back()) {
				op[++tot]=make_pair(j,k);
				Q[j].pop_back();
				Q[k].pop_back();
				r-=2;
			}
		dfs(step+1,r);
		Q[i]=Qt;
	}
}
inline void solve() {
	if(n==2) {
		Q[1].push_back(a[1]);
		puts("1 1");
		For(i,2,m) {
			if(a[i]==Q[1].back()) {
				puts("1 2");
				puts("2 1 2");
			}
			else
				puts("1 1");
		}
		return;
	}
	if(n==3) {
		dfs(1,m);
	}
}
signed main() {
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	cin>>T;
	while(T--) {
//		mem;
		scanf("%lld%lld%lld",&n,&m,&k);
		For(i,1,m) scanf("%lld",&a[i]);
		solve();
	}
	return 0;
}

