#include<bits/stdc++.h>
#define LL long long
#define reg register
using namespace std;
const int N = 2e6 + 10; 
inline int read();
struct node{
	int top = 0,end = 0;
}t[500];//栈 
int vis[10000],T,n,m,k,val[N],cnt;
//val存牌堆
//vis存牌是否在栈中 
struct root{
	int style = 0;
	int a = 0,b = 0;
}ans[100000];
priority_queue<int,vector<int>,greater<int> > q;//栈是否满了
priority_queue<int,vector<int>,greater<int> > v;//下栈是否为空
//可以写个优先队列维护空的栈，每次取最小的放置
inline void input(){
	//初始化
	node stand;
	root check;
	for(int i = 1;i <= cnt;i++){
		ans[i] = check;
	}
	cnt = 0;
	memset(vis,0,sizeof(vis));
	while(!q.empty()) q.pop();
	while(!v.empty()) v.pop();
	n = read(),m = read(),k = read();
	for(int i = 1;i <= m;i++)
		val[i] = read();
	for(int i = 1;i <= n;i++){
		t[i] = stand;//栈的初始化
		q.push(i);//别忘了把栈存入优先队列中 
		v.push(i);
	}
	
	//输入处理 
	//调试 
	//for(int i = 1;i <= m;i++)
	//	std::cout<<val[i]<<" ";
}
//处理模块 
inline void put(int style,int a,int b){
	root cr;
	cr.style = style;
	if(style == 2){
		cr.b = b;
	}
	cr.a = a;
	ans[++cnt] = cr;
}
inline void deal(){
	for(int i = 1;i <= m;i++){
		//先取数 
		int x = val[i];
		//判断是否出现过
		//特殊情况,等会考虑 
		if(vis[x]){
			//出现过把他消掉
			//要判断在栈顶还是在栈尾 
			if(t[vis[x]].top == x || t[vis[x]].top == 0){
				put(1,vis[x],0);
				//维护
				q.push(vis[x]);//栈不满了 
				t[vis[x]].top = 0;
				vis[x] = 0;
			}
			else{
				int cnd = v.top();//下栈为空的 做消除 
				//
				put(1,cnd,0);
				//先放入 在消除
				put(2,vis[x],cnd); 
				if(t[vis[x]].top) {
					t[vis[x]].end = t[vis[x]].top;
				}
				else{
					v.push(vis[x]);
				}
				q.push(vis[x]);
				t[vis[x]].top = 0;
				vis[x] = 0;
			}
		} 
		else{
			int cnd = q.top();
			vis[x] = cnd;
			if(t[vis[x]].end) {
				t[vis[x]].top = x;
				q.pop();
			}
			else {
				t[vis[x]].end = x;
				v.pop();
			}
			put(1,cnd,0);
		}
	}
}
inline void output(){
	std::cout<<cnt<<endl;
	for(reg int i = 1;i <= cnt;i++){
		std::cout<<ans[i].style<<" "<<ans[i].a<<" ";
		ans[i].style == 2 ? std::cout<<ans[i].b<<endl : std::cout<<endl;
	}
}
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	T = read();
	while(T--){
		input();
		deal();
		output();
	}
	return 0;
}
inline int read(){
	int n = 0;char ch = getchar();
	while( ch < '0' || ch > '9') ch = getchar();
	while(ch >= '0' && ch <= '9'){
		n = (n << 3) + (n << 1) + (ch ^ 48);
		ch = getchar();
	}
	return n;
}

