#include<bits/stdc++.h>
using namespace std;

int T,top[400],flor[400],a[2000100],op,i;

int main()
{
	freopen ("meow.in","r",stdin);
	freopen ("meow.out","w",stdout);
	
	cin>>T;
	while (T>0)
	{
		T-=1;
		int n,m,k;
		op=0;
		
		scanf("%d%d%d",&n,&m,&k);
		
		for (i=1;i<=n;i++)
		{
			top[i]=0;
			flor[i]=0;
		}
		
		for (i=1;i<=m;i++)
		{
			scanf("%d",&a[i]);
			int j;
			j=(a[i]+1)/2;
			if (flor[j]==0&&top[j]==0) 
			{
				flor[j]=a[i];
				op+=1;
				continue;
			}
			if (top[j]==0)
			{
				if (flor[j]==a[i]) flor[j]=0;
				else top[j]=a[i];
				op+=1;
				continue;
			}
			
			if (top[j]==a[i]) top[j]=0,op+=1;
			else flor[j]=top[j],top[j]=0,op+=2;
			
		}
		
		cout<<op<<endl;
		
		
		for (i=1;i<=n;i++)
		{
			top[i]=0;
			flor[i]=0;
		}
		
		for (i=1;i<=m;i++)
		{
			int j;
			j=(a[i]+1)/2;
			if (flor[j]==0&&top[j]==0) 
			{
				flor[j]=a[i];
				printf("1 %d\n",j);
				continue;
			}
			if (top[j]==0)
			{
				if (flor[j]==a[i]) {flor[j]=0;printf("1 %d\n",j);}
				else {top[j]=a[i];printf("1 %d\n",j);}
				continue;
			}
			
			if (top[j]==a[i]) {top[j]=0;printf("1 %d\n",j);}
			else {flor[j]=top[j];top[j]=0;printf("1 %d\n",n);printf("2 %d %d\n",j,n);}
			
		}
		
		
	}
	
	
	return 0;
}