#include <iostream>
#include <cstdio>
#include <deque>

namespace SuperI{
	const int MBUF = 2 << 21;
	std::streambuf *inbuf = std::cin.rdbuf();
	char buf[MBUF], *head = buf, *tail = buf, ___c;
	inline char getchar() {
		if ((head == tail) && (tail = (head = buf) + inbuf->sgetn(buf, MBUF), head == tail)) return EOF;
		else return *head++;
	}
	inline void read(int *const p) {
		*p = 0;
		for (___c = getchar(); ___c < '0' || ___c > '9';)
		___c = getchar();
		for (; ___c >= '0' && ___c <= '9'; *p = *p * 10 + (___c ^ 48), ___c = getchar());
	}
	inline void read(long long *const p) {
		*p = 0;
		for (___c = getchar(); ___c < '0' || ___c > '9'; ___c = getchar());
		for (; ___c >= '0' && ___c <= '9'; *p = *p * 10 + (___c ^ 48), ___c = getchar());
	}
}

int T;
int n, m, k;
int a[2000005];
int pos[605];
int ans[4000005][2], l;
std::deque<int> q[305];

int main() {
	using SuperI::read;
	freopen("meow.in", "r", stdin);
	freopen("meow.out", "w", stdout);
	
	read(&T);
	for (int t = 1; t <= T; ++t) {
		read(&n);
		read(&m);
		read(&k);
		for (int i = 1; i <= k; ++i) pos[i] = 0;
		for (int i = 1; i <= m; ++i) read(a + i);
		int cnt = 1;
		l = 0;
		for (int i = 1; i <= m; ++i) {
			if (pos[a[i]]) {
				if ((!q[pos[a[i]]].empty()) && q[pos[a[i]]].front() == a[i]) {
					ans[++l][0] = 1;
					ans[l][1] = n;
					ans[++l][0] = 2;
					ans[l][1] = pos[a[i]];
					q[pos[a[i]]].pop_front();
				}
				else if ((!q[pos[a[i]]].empty()) && q[pos[a[i]]].back() == a[i]) {
					ans[++l][0] = 1;
					ans[l][1] = pos[a[i]];
					q[pos[a[i]]].pop_back();
				}
				else {
					q[pos[a[i]]].push_back(a[i]);
					ans[++l][0] = 1;
					ans[l][1] = pos[a[i]];
				}
			}
			else {
				pos[a[i]] = (++cnt) / 2;
				q[pos[a[i]]].push_back(a[i]);
				ans[++l][0] = 1;
				ans[l][1] = pos[a[i]];
			}
		}
		std::cout << l << '\n';
		for (int i = 1; i <= l; ++i)
			if (ans[i][0] == 1) std::cout << "1 " << ans[i][1] << '\n';
			else std::cout << "2 " << ans[i][1] << ' ' << n << '\n';
	}

	fclose(stdin);
	fclose(stdout);
	return 0;
}
