#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 5;
int n, m, K, a[N];
deque<int> stk[N];
bool ans;
struct rec {
	int op, x, y;
	rec(int _op, int _x, int _y) {
		op = _op, x = _x, y = _y;
	}
};
vector<rec> pp;
vector<pair<int, int> > cc;
void dfs(int x) {
	if (ans) return;
	if (x == m + 1) {
		int cnt = 0;//vector<rec> d = pp;
		cc.clear();
		while (1) {
			bool flag = 1;
			for (int i = 1; i <= n; ++i) flag &= stk[i].empty();
			if (flag) break;
			bool ff = 0;
			for (int i = 1; i <= n; ++i)
				for (int j = i + 1; j <= n; ++j) 
					if (stk[i].size() && stk[j].size() && stk[i].front() == stk[j].front()) {
						cc.push_back(make_pair(i, stk[i].front()));
						cc.push_back(make_pair(j, stk[j].front()));
						stk[i].pop_front();
						stk[j].pop_front();
						++cnt;
						pp.push_back(rec(2, i, j));
						ff = 1;
						break;				
					} 
			if (!ff) break;
		}
		bool flag = 1;
		for (int i = 1; i <= n; ++i) flag &= stk[i].empty();//cout << "!!"<< flag << endl;
		if (flag) { 
			for (auto x : pp)
				if (x.op == 1) printf("1 %d\n", 1, x.x);
				else printf("2 %d %d\n", x.x, x.y);
			ans = 1;
		} else {
			for (int i = 1; i <= cnt; ++i) pp.pop_back();
			reverse(cc.begin(), cc.end());
			for (auto x : cc) stk[x.first].push_front(x.second);
		}
		return;
	}
	bool ff = 1;
	for (int i = 1; i <= n; ++i)
		if (stk[i].size() && stk[i].back() == a[x]) {
			stk[i].pop_back();
			pp.push_back(rec(1, i, 0));
			dfs(x + 1);
			pp.pop_back();
			ff = 0;
		}
	if (ff)
		for (int i = 1; i <= n; ++i) {
			stk[i].push_back(a[x]);
			pp.push_back(rec(1, i, 0));
			dfs(x + 1);
			pp.pop_back();
			stk[i].pop_back();
		}
}
void Solution() {
	cin >> n >> m >> K;
	for (int i = 1; i <= m; ++i) scanf("%d", a + i);
	ans = 0;
	dfs(1);
}
int main() {
	freopen("meow.in", "r", stdin);
	freopen("meow.out", "w", stdout);
	int T;
	cin >> T;
	while (T--) Solution();
}
