#include<bits/stdc++.h>
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9') f=(ch=='-')?-1:1,ch=getchar();
	while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x*f;
}
const int M=2000005,N=305;
int a[M],ne[M],top[N],endd[N],v[N<<1];
int opt[M],l[M],r[M],tot;
int n,m,k;
deque<int> q[N];
priority_queue<int,vector<int>,greater<int>> kong,zk;
int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int t=read();
	while(t--)
	{
		memset(v,0,sizeof(v)),memset(endd,0,sizeof(endd)),memset(top,0,sizeof(top)),tot=0;
//		cout<<kong.empty()<<endl;
		while(!kong.empty()) kong.pop();
		while(!zk.empty()) zk.pop();
		n=read(),m=read(),k=read();
//		cout<<'j'<<endl;
		for(int i=1;i<=n;i++) kong.push(i),zk.push(i),q[i].clear();
		for(int i=1;i<=m;i++) a[i]=read();
		for(int i=m;i>=1;i--) ne[i]=v[a[i]],v[a[i]]=i;
		for(int i=1;i<=m;i++)
		{
//			cout<<top[a[i]]<<' '<<endd[a[i]]<<endl;
			if(endd[a[i]])
			{
//				cout<<i<<endl;
				int x=endd[a[i]];
				opt[++tot]=1,l[tot]=x,q[x].pop_back(),endd[a[i]]=0;
				if(!q[x].empty()) endd[a[q[x].back()]]=x;
				else top[a[i]]=0,zk.push(x);
				if(q[x].size()==1) kong.push(x);	
				continue;
			}
			if(top[a[i]])
			{
				int x=top[a[i]];
				opt[++tot]=1,l[tot]=zk.top(),opt[++tot]=2,l[tot]=x,r[tot]=zk.top();
				q[x].pop_front(),top[a[i]]=0;
				top[a[q[x].front()]]=x;
				if(q[x].size()==1) kong.push(x);
				continue;
			}
			if(kong.size()!=1)
			{
				int x=kong.top();
				opt[++tot]=1,l[tot]=x;
				if(q[x].empty()) top[a[i]]=x,zk.pop();
				else kong.pop(),endd[a[q[x].back()]]=0;
				endd[a[i]]=x,q[x].push_back(i);
				continue;
			}
			int maxx=1,z=1e9;
			for(int j=1;j<=n;j++)
			{
				if(q[j].empty()) continue;
				int y=ne[q[j].front()]-ne[q[j].back()];
				if(y<z) z=y,maxx=j;
			}
			if(z>0)
			{
				opt[++tot]=1,l[tot]=zk.top();
				top[a[i]]=zk.top(),endd[a[i]]=zk.top(),q[zk.top()].push_back(i),zk.pop();
			}
			else
			{
				opt[++tot]=1,l[tot]=maxx;
				endd[a[q[maxx].back()]]=0,endd[a[i]]=maxx,q[maxx].push_back(i);
			}
		}
		printf("%d\n",tot);
		for(int i=1;i<=tot;i++)
		{
			printf("%d ",opt[i]);
			if(opt[i]==1) printf("%d\n",l[i]);
			else printf("%d %d\n",l[i],r[i]);
		}
	}
	return 0;
}
/*
1
3 10 5
1 2 3 4 5 2 3 4 5 1
*/
/*10:21 I have an idea*/
/*when there are 2*n-2 numbers in the stack*/
/*if all tops are later than ends,the (n*2-1)th will be place on the top*/
/*else the (n*2-1)th will be place at the end of the stack which the top is earlier than the end*/