#include <bits/stdc++.h>

const int N = 600 + 5;
const int M = 4e6 + 10;
std::mt19937 rnd(20051107);

std::deque<int> sta[N];

struct opt {
	int type;
	int s1, s2;
} opt[M];
int id[M], col[M];
int pre[M], nxt[M];
int lst[N];
void sovle() {
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	int cnt = 0;
	auto op1 = [&](int s, int x) {
		++cnt;
		opt[cnt].type = 1;
		opt[cnt].s1 = s;
		if (!sta[s].empty() && sta[s].back() == x) sta[s].pop_back();
		else sta[s].push_back(x);
		return;
	};
	auto op2 = [&](int s1, int s2) {
		++cnt;
		opt[cnt].type = 1;
		opt[cnt].s1 = s1;
		opt[cnt].s2 = s2;
		sta[s1].pop_front();
		sta[s2].pop_front();
		return;
	};
	for (int i = 1; i <= m; ++i) {
		scanf("%d", col + i);
		if (lst[col[i]] == 0) lst[col[i]] = i;
		else {
			pre[i] = lst[col[i]];
			nxt[lst[col[i]]] = i;
			lst[col[i]] = 0;
		}
	}
	std::vector<int> arr(n - 1);
	std::iota(arr.begin(), arr.end(), 1);
	std::shuffle(arr.begin(), arr.end(), rnd);
	for (int i = 1; i <= m; ++i) {
		if (!id[col[i]]) {
			if (!arr.empty()) {
				int x = arr.back();
				op1(x, col[i]);
				id[col[i]] = x;
				if (sta[x].size() >= 2) arr.pop_back();
			}
			else {
				int x = rnd() % (n - 1) + 1;
				op1(x, col[i]);
				id[col[i]] = x;
			}
		}
		else {
			int x = id[col[i]];
			if (sta[x].back() == col[i]) {
				op1(x, col[i]);
				if (sta[x].size() < 2) arr.push_back(x);
				id[col[i]] = 0;
			}
			else if (sta[x].front() == col[i]) {
				op1(n, col[i]);
				op2(x, n);
				if (sta[x].size() < 2) arr.push_back(x);
				id[col[i]] = 0;
			}
			else assert(0);
		}
	}
	printf("%d\n", cnt);
	for (int i = 1; i <= cnt; ++i) {
		if (opt[i].type == 1) printf("1 %d\n", opt[i].s1);
		else printf("2 %d %d\n", opt[i].s1, opt[i].s2);
	}
	return;
}
int main() {
	freopen("meow.in", "r", stdin);
	freopen("meow.out"," w", stdout);

	int T;
	scanf("%d", &T);
	while (T--) sovle();
	return 0;
}