#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#define up(i, a, b) for (int i = a; i <= b; i++)
#define dn(i, a, b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long ll;
int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-') f = -1;ch = getchar();}
	while (ch >= '0' && ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return x * f;
}
const int N = 605, M = 2e6 + 5;
int n, m, k, a[N], b1[N], b2[N], cnt;
int vis[N], pos[N];
struct Answer{
	int op, s1, s2;
}p[N];
void insert(int x) {
	up(i, 1, n - 1) {
		if (!b1[i]) {
			b1[i] = x, pos[x] = i;
			return;
		}
		else if (!b2[i]) {
			b2[i] = x, pos[x] = i;
			return;
		}
	}
}
void solve1() {
	n = read(), m = read(), k = read();
	cnt = 0;
	up(i, 1, n) b1[i] = b2[i] = 0;
	up(i, 1, k) pos[i] = 0;
	up(i, 1, m) a[i] = read();
	up(i, 1, m) {
		if (pos[a[i]]) {
			if (b2[pos[a[i]]] == a[i]) {
				p[++cnt] = {1, pos[a[i]], 0};
//				printf("1 %d\n", pos[a[i]]);
				b2[pos[a[i]]] = 0;
			}
			else {
				p[++cnt] = {1, n, 0};
				p[++cnt] = {2, pos[a[i]], n};
//				printf("1 %d\n", n);
//				printf("2 %d %d\n", pos[a[i]], n);
				b1[pos[a[i]]] = b2[pos[a[i]]], b2[pos[a[i]]] = 0;
			}
			pos[a[i]] = 0;
		}
		else {
			insert(a[i]);
			p[++cnt] = {1, pos[a[i]], 0};
//			printf("1 %d\n", pos[a[i]]);
		}
	}
	printf("%d\n", cnt);
	up(i, 1, cnt) {
		int op = p[i].op, s1 = p[i].s1, s2 = p[i].s2;
		if (op == 1) printf("%d %d\n", op, s1);
		else printf("%d %d %d\n", op, s1, s2);
	}
}
int main() {
//	freopen("meow1.in", "r", stdin);
	freopen("meow.in", "r", stdin);
	freopen("meow.out", "w", stdout);
	int T = read();
	while (T--) solve1();
	return 0;
}









