#include<bits/stdc++.h>

using namespace std;

int t,n,m,k;
int a[2000005];

void cheat1()
{
	int i,j,x;
	int nn[600];
	int cs[600];//mark the number from 1~k;
	int pd[305];//0front 1last
	
	int ss=0;
	memset(pd,-1,sizeof(pd));
	memset(cs,0,sizeof(cs));
	memset(nn,0,sizeof(nn));
	int sum=1;
	for (i=1;i<=m;i++)
	{
		x=a[i];
		if (cs[x]==0) 
		{
			sum+=1;
			cs[x]=sum;
			nn[sum]+=1;
			pd[sum/2]=sum%2;
			printf("1 %d\n",sum/2);
		}
		else 
		{
			int zb,z;
			zb=cs[x]/2;
			z=cs[x]%2;
			if (pd[zb]==-1&&nn[zb]<=0)
			{
				printf("1 %d\n",zb);
				pd[zb]=z;
				nn[zb]++;
				continue;
			}
			//cout << zb << endl;
			if (pd[zb]!=z)
			{
				printf("1 %d\n",n);
				printf("2 %d %d\n",zb,n);
				nn[zb]-=1;
				if (nn[zb]<=0) pd[zb]=-1,nn[zb]=0;
				if (pd[zb]==1) pd[zb]=0;
				else 
				{
					if (pd[zb]==0) pd[zb]=1;
				} 
			} else
			{
				printf("1 %d\n",zb);
				nn[zb]-=1;
				if (nn[zb]<=0) pd[zb]=-1,nn[zb]=0;
				if (pd[zb]==1) pd[zb]=0;
				else 
				{
					if (pd[zb]==0) pd[zb]=1;
				} 
			}
		}
	}
	
	return;
}

void cheatjs()
{
	int i,j,x;
	int nn[600];
	int cs[600];//mark the number from 1~k;
	int pd[305];//0front 1last
	
	int ss=0;
	memset(pd,-1,sizeof(pd));
	memset(cs,0,sizeof(cs));
	memset(nn,0,sizeof(nn));
	int sum=1;
	for (i=1;i<=m;i++)
	{
		scanf("%d",&a[i]);
		x=a[i];
		if (cs[x]==0) 
		{
			sum+=1;
			cs[x]=sum;
			nn[sum]+=1;
			pd[sum/2]=sum%2;
			ss++;
		}
		else 
		{
			int zb,z;
			zb=cs[x]/2;
			z=cs[x]%2;
			if (pd[zb]==-1&&nn[zb]<=0)
			{
				ss++;
				pd[zb]=z;
				nn[zb]++;
				continue;
			}
			//cout << zb << endl;
			if (pd[zb]!=z)
			{
			    ss+=2;
				nn[zb]-=1;
				if (nn[zb]<=0) pd[zb]=-1,nn[zb]=0;
				if (pd[zb]==1) pd[zb]=0;
				else 
				{
					if (pd[zb]==0) pd[zb]=1;
				} 
			} else
			{
				ss++;
				nn[zb]-=1;
				if (nn[zb]<=0) pd[zb]=-1,nn[zb]=0;
				if (pd[zb]==1) pd[zb]=0;
				else 
				{
					if (pd[zb]==0) pd[zb]=1;
				} 
			}
		}
	}
	
	cout << ss << endl;
	
	return;
}

int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	
	int tt;
	scanf("%d",&t);
	tt=t;
	while (tt--)
	{
		scanf("%d%d%d",&n,&m,&k);
		//if (t%1000==1) 
		cheatjs();
		cheat1();
	}
	
	
	return 0;
}
