#include <iostream>
#include <cstdio>
#include <queue>
#include <deque>
using namespace std;
int t;
long long m;
int n, k, tmp;
deque<int> pile;
deque<int> stks[305];
struct oper{
	bool type;
	int opr1, opr2;
	oper(bool tp=1, int o1=0, int o2=0){
		type=tp;
		opr1=o1, opr2=o2;
	}
	void output(){
		if (type) printf("1 %d\n", opr1+1);
		else printf("2 %d %d\n", opr1+1, opr2+1);
	}
};
deque<oper> opss;

bool ended = 0;
void dfs(){
	bool tag = 0;
	if (pile.size()>0) tag = 1;
	if (!tag){
		for (int i=0;i<n;i++) {
			if (stks[i].size()>0) tag = 1;
			if (tag) break;
		}
		if (!tag) ended = 1;
		if (ended) return;
	}
	if (pile.size()>0){
		tag = 1;
		int bott = pile.front();
		pile.pop_front();
		for (int i=0;i<n;i++){
			opss.push_back(oper(1, i, 0));
			bool tag = 0;
			if (stks[i].size()>0 && stks[i].back()==bott){
				tag = 1;
				stks[i].pop_back();
			} else stks[i].push_back(bott);
			dfs();
			if (ended) return;
			if (tag) stks[i].push_back(bott);
			else stks[i].pop_back();
			opss.pop_back();
		}
		pile.push_front(bott);
	}
	for (int i=0;i<n;i++){
		if (stks[i].size()==0) continue;
		for (int j=i+1;j<n;j++){
			if (stks[j].size()==0) continue;
			tag = 1;
			if (stks[i].front()==stks[j].front()){
				opss.push_back(oper(0, i, j));
				int outpop = stks[i].front();
				stks[i].pop_front();
				stks[j].pop_front();
				dfs();
				if (ended) return;
				stks[i].push_front(outpop);
				stks[j].push_front(outpop);
				opss.pop_back();
			}
		}
	}
}
int main(){
	freopen("meow1.in", "r", stdin);
	freopen("meow.out", "w", stdout);
	cin>>t;
	for (int teamcnt=0; teamcnt<t; teamcnt++){
		scanf("%d %lld %d", &n, &m, &k);
		for (long long i=0;i<m;i++){
			scanf("%d", &tmp);
			pile.push_front(tmp);
		}
		dfs();
		printf("%d\n", (int)(opss.size()));
		while (opss.size()>0){
			opss.front().output();
			opss.pop_front();
		}
		opss.clear();
		pile.clear();
		for (int i=0;i<n;i++) stks[i].clear();
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}