#include<bits/stdc++.h>
using namespace std;
int T,n,m,k,op,a[2000005],sum[305],ne[2000005],h[605],ans[2000005],ansl[2000005],ansr[2000005],
tag[2000005],pre[2000005],prel[2000005],preop[2000005];
bool f[2000005],ff[2000005];
int read()
{
	int x=0,p=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-') p=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*p;
}
int check(int x,int y)
{
	int s=0;
	while(a[x]==a[y])
	{
		x++;y++;
		s++;
	}
	return s;
}
int getmin()
{
	int minn=0x7fffffff,x;
	for(int i=1;i<=n;i++)
		if(sum[i]<minn)
			minn=sum[i],x=i;
	return x;
}
int getfree()
{
	for(int i=1;i<=n;i++)
		if(sum[i]==0) return i;
	return getmin();
}
int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	T=read();
	while(T--)
	{
		n=read();m=read();k=read();
		for(int i=1;i<=m;i++)
			a[i]=read();
		for(int i=m;i>=1;i--)
		{
			ne[i]=h[a[i]];
			h[a[i]]=i;
		}
		for(int i=1;i<=m;i++)
		if(!f[i])
		{
			int x=check(i,ne[i]);
			if(i+x==ne[i]&&x<=n)
			{
				op++;ans[op]=1;ansl[op]=1;
				for(int j=i+1;j<=i+x-1;j++)
				{f[j]=1;preop[j]=1;prel[j]=j-i+1;}
				for(int j=ne[i];j<=ne[i]+x-1;j++)
				{f[j]=1;preop[j]=1;prel[j]=j-ne[i]+1;}
				continue;
			}
			if(x==1)
			{
				int y=getfree();
				op++;
				ans[op]=1;ansl[op]=y;sum[y]++;
				tag[ne[i]]=-1;f[ne[i]]=1;
				preop[ne[i]]=1;prel[ne[i]]=y;
			}
			else
			{
				int y=getfree();
				op++;ans[op]=1;ansl[op]=y;sum[y]++;
				for(int j=i+1;j<=i+x-1;j++)
				{f[j]=1;tag[i]=1;preop[j]=1;prel[j]=y;}
				for(int j=ne[i];j<=ne[i]+x-1;j++)
				{f[j]=1;preop[j]=2;prel[j]=y;}
				pre[ne[i]]=x;
			}
		}
		else
		{
			if(preop[i]==1)
			{
				op++;
				ans[op]=1;
				ansl[op]=prel[i];
				sum[prel[i]]+=tag[i];
			}
			else
				if(!ff[i])
				{
					int y=getfree();
					for(int j=i;j<=i+pre[i]-1;j++)
					{
						ff[j]=1;
						op++;ans[op]=1;ansl[op]=y;
						op++;ans[op]=2;ansl[op]=prel[j];ansr[op]=y;
					}
				}
		}
		cout<<op;putchar('\n');
		for(int i=1;i<=op;i++)
			if(ans[i]==1)
				{putchar('1');putchar(' ');cout<<ansl[i];putchar('\n');}
			else
				{putchar('2');putchar(' ');cout<<ansl[i];putchar(' ');cout<<ansr[i];putchar('\n');}
		for(int i=1;i<=m;i++)
			f[i]=0,ff[i]=0;
		op=0;
	}
}