#include<bits/stdc++.h>
using namespace std;
const int N=3e2+10;
int T;
int n,m,k;
int id[N<<1];//1~n=low,n+1~2n=top
map<int,int> mp;//1~n=low,n+1~2n=top
queue<int> q1,q2,q3,q4;
struct node
{
	int u,v,w;
};
vector<node> op;
void push(int x,int t)
{
	if(t<=n)
	{
		id[t]=id[t+n];
		mp[id[t]]=t;
		t+=n;
	}
	else q2.push(t-n);
	mp[x]=t;
	id[t]=x;
	op.push_back({1,t-n,0});
}
void pop(int t)
{
	int x=id[t];
	if(mp[x]<=n)
	{
		id[mp[x]]=0;
		mp[x]=0;
		q2.push(mp[x]);
	}
	else
	{
		int y=id[mp[x]-n];
		if(y==0) q1.push(mp[x]);
		else
		{
			q2.push(mp[y]);
			mp[y]+=n;
			id[mp[y]]=y;
		}
		mp[x]=0;
		id[mp[x]]=0;
	}
}
void init()
{
	while(!q1.empty()) q1.pop();
	while(!q2.empty()) q2.pop();
	while(!q3.empty()) q3.pop();
	while(!q4.empty()) q4.pop();
	mp.clear();
	memset(id,0,sizeof id);
	op.clear();
}
void solve()
{
	init();
	cin>>n>>m>>k;
	for(int i=n+1;i<=2*n;i++) q1.push(i);
	for(int i=1,x;i<=m;i++)
	{
		cin>>x;
		if(mp[x]>n)
		{
			op.push_back({1,mp[x]-n,0});
			pop(mp[x]);
		}
		else if(!q3.empty())
		{
			int tmp=mp[x];
			push(x,q3.front());
			q3.pop();
			op.push_back({2,q4.front(),mp[x]-n});
			pop(q4.front());
			pop(mp[x]-n);
			q4.pop();
			if(tmp)
			{
				op.push_back({2,tmp,mp[x]-n});
				pop(tmp);
				pop(mp[x]-n);
			}
		}
		else if(mp[x]>0)
		{
			if(!q1.empty())
			{
				op.push_back({1,q1.front()-n,0});
				op.push_back({2,q1.front()-n,mp[x]});
				pop(q1.front());
				q1.pop();
			}
			else
			{
				q4.push(mp[x]);//<=n
				push(x,q2.front());
				q3.push(q2.front());
				q2.pop();
			}
		}
		else 
		{
			if(!q2.empty()) 
			{
				push(x,q2.front());
				q2.pop();
			}
			else 
			{
				push(x,q1.front());
				q1.pop();
			}
		}
	}
	while(!q4.empty())
	{
		op.push_back({2,q3.front(),q4.front()});
		q3.pop();q4.pop();
	}
	cout<<op.size()<<endl;
	for(node x:op) 
	{
		cout<<x.u<<' '<<x.v<<' ';
		if(x.w) cout<<x.w;
		cout<<'\n';
		
	}
}
signed main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>T;
	while(T--) solve();
}