#include<bits/stdc++.h>
using namespace std;
#define M 2000006 
#define N 303
#define ll long long
int t, n, m;
int k, a[M], nxt[M], lst[M];
int id[N];
int que[N][3];    // store the nxt
struct ans{
	int x, y, z;
} ANS[2*M];
int anscnt;
void add(int p, int x){
	anscnt ++;
	ANS[anscnt].x = 1; ANS[anscnt].y = p;
	id[a[x]] = p;
	if(que[p][0] == 0){
		que[p][0] = nxt[x];
	} else if(que[p][1] == 0){
		que[p][1] = nxt[x];
	} else {
		que[p][2] = nxt[x];
	}
}
void era_tp(int p){
	anscnt ++;
	ANS[anscnt].x = 1; ANS[anscnt].y = p;
	if(que[p][2] != 0){
		que[p][2] = 0;
	} else if(que[p][1] != 0){
		que[p][1] = 0;
	} else {
		que[p][0] = 0;	
	}
}
void era_ed(int p){
	anscnt ++;
	ANS[anscnt].x = 1; ANS[anscnt].y = n;
	anscnt ++;
	ANS[anscnt].x = 2; ANS[anscnt].y = p; ANS[anscnt].z = n;
	que[p][0] = que[p][1];
	que[p][1] = que[p][2];
	que[p][2] = 0;
	
}
void solve(){
	for(int i=1;i<=m;i++){
		int col = a[i];
		if(id[col]){
			int now = id[col];
			if(que[now][0] == i){
				era_ed(now);
			} else{
				era_tp(now);
			}
		} else{
			int now = 0;
			while(true){
				now ++;
				if(que[now][2] != 0) continue;
				bool y = false;
				if(que[now][1] != 0){
					if(que[now][0] < que[now][1]) y = false;
					else y = true;
				}
				if(y == false && que[now][0] < nxt[i]) break;
				if(que[now][1] == 0 && que[now][0] > nxt[i]) break;
				if(y == true && que[now][1] > nxt[i]) break; 
			}
			add(now, i);
		}
	}
}
int main(){
	freopen("meow.in", "r", stdin);
	freopen("meow.out", "w", stdout);
	cin>>t;
	while(t--){
		scanf("%d%d%d", &n, &m, &k);
		anscnt = 0;
		for(int i=1;i<=m;i++) scanf("%d", a+i);
		memset(que, 0, sizeof que);
		for(int i=1;i<=m;i++){
			nxt[lst[a[i]]] = i;
			lst[a[i]] = i;
			nxt[i] = n+1;
		}
		solve();
		printf("%d\n", anscnt);
		for(int i=1;i<=anscnt;i++){
			if(ANS[i].x == 1){
				printf("%d %d\n", ANS[i].x, ANS[i].y);
			} else{
				printf("%d %d %d\n", ANS[i].x, ANS[i].y, ANS[i].z);
			}
		}
	}
}
