#include<bits/stdc++.h>
using namespace std;
const int N=395;
const int M=2e6+88;
bool vis[N*2+100];
int val[N];
int a[M];
int num[N*2+100];
int n,m,k;
struct sange
{
	int yi,er,san;
};
int main() {
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int T;
	cin.tie(0);
	ios::sync_with_stdio(0);
	cin>>T;
	while(T--) {
		vector<sange> ans;
		deque<int> q[2];
		memset(vis,0,sizeof vis);
		memset(val,0,sizeof val);
		memset(num,0,sizeof num);
		cin>>n>>m>>k;
		for(int i=1; i<=m; ++i) {
			cin>>a[i];
		}
		int cnt=2;
		for(int i=1; i<=m; ++i) {
			if(vis[a[i]]==0) {
				q[1].push_back(a[i]);
				vis[a[i]]=1;
				val[1]=-1;
				ans.push_back({1,1,0});
			} else {
				bool flag=0;
				int uuu=0;
				for(int j=2; j<=n; ++j) {
					if(val[j]==a[i]) {
						uuu=j;
						flag=1;
						break;
					}
				}
				if(flag) {
					for(int j=2; j<=n; ++j) {
						if(val[j]==0) {
							ans.push_back({1,j,0});
							ans.push_back({2,uuu,j});
							break;
						}
					}
		
					val[uuu]=0;
					continue;
				}
//				q[cnt].puhs_back(a[i]);
				num[a[i]]=cnt;
				if(val[cnt]) {
					for(int j=2; j<=n; ++j) {
						if(val[j]==0) {
							val[j]=a[i];
							num[a[i]]=j;
						}
					}
				}
				ans.push_back({1,num[a[i]],0});
				while(num[q[1].back()]!=0) {
//						q[num[q[1].back()]].pop_back();
					val[num[q[1].back()]]=0;
					num[q[1].back()]=0;
					vis[q[1].back()]=0;
					q[1].pop_back();
				}
				while(num[q[1].front()]!=0) {
					ans.push_back({2,num[q[1].front()],1});
					val[num[q[1].front()]]=0;
					num[q[1].front()]=0;
					vis[q[1].front()]=0;
					q[1].pop_front();
				}
				cnt++;
				if(cnt>n) cnt=2;
			}
		}
		cout<<ans.size()<<"\n";
		for(int i=0;i<ans.size();++i)
		{
			if(ans[i].yi==1)
			{
				cout<<ans[i].yi<<" "<<ans[i].er<<"\n";
			}
			else
			{
				cout<<ans[i].yi<<" "<<ans[i].er<<" "<<ans[i].san<<"\n";
			}
		}
	}
}