#include <bits/stdc++.h>
using namespace std;

const int MAX_M = 5e4 + 10;
const int MAX_N = 310;
const int MAX_K = MAX_N << 1;

struct DO{
	int s, v1, v2;
};

mt19937 rd(time(0));
int T;
int n, m, k;
int a[MAX_M];
int pre[MAX_K], nxt[MAX_K];
int st[MAX_N][MAX_M];
int low[MAX_N], head[MAX_N];
bool mk[MAX_N][2];
vector<DO> lis;

void read(int &x){
	char c = getchar(); x = 0;
	while (!isdigit(c)) c = getchar();
	while ( isdigit(c)) x = x * 10 + (c ^ '0'), c = getchar();
	return;
}

int main(){
	freopen("meow.in", "r", stdin);
	freopen("meow.out", "w", stdout);
	read(T);
	while (T--){
		lis.clear();
		read(n); read(m); read(k); int rm = n;
		int cnt = 0;
		for (int i = 1; i <= m; i++){
			read(a[i]);
//			if (pre[a[i]]){
//				cnt--;
//				st[pre[a[i]]][0] = i;
//				st[i][1] = pre[a[i]];
//				pre[a[i]] = 0;
//			}else{
//				cnt++;
//				pre[a[i]] = i;
//			}
		}
		for (int i = 1; i <= n; i++){
			head[i] = 0;
			low[i] = 1;
		}
		for (int i = 1; i <= m; i++){
			bool mark = true;
			for (int j = 1; j < n; j++){
				if (head[j] < low[j]) continue;
				if (st[j][head[j]] == a[i]){
					lis.push_back((DO) {1, j, 0});
					head[j]--;
					mark = false;
					break;
				}
				if (st[j][low[j]] == a[i]){
					lis.push_back((DO) {1, n, 0});
					lis.push_back((DO) {2, j, n});
					low[j]++;
					mark = false;
					break;
				}				
			}
			if (mark){
				int to = rd() % (n - 1) + 1;
				st[to][++head[to]] = a[i];
				lis.push_back((DO) {1, to, 0});
			}
		}
		printf("%d\n", lis.size());
		for (int i = 0; i < lis.size(); i++){
			if (lis[i].s == 1){
				printf("1 %d\n", lis[i].v1);
			}else{
				printf("2 %d %d\n", lis[i].v1, lis[i].v2);
			}
		}
	}
	return 0;
}
