//Can Zhang Haibo AK NOIP?
#include<bits/stdc++.h>
using namespace std;
int a[2000005]={0},bok[100000][3]={0};
bool small_black=false;
struct edge
{
	int zhiyin[100],number;
	edge()
	{
		number=0;
	}
}book[305],book1[305];
int readd()
{
	int f=1,x=0;
	char str=getchar();
	while(str<'0'||str>'9')
	{
		if(str=='-')
		 f=-1;
		str=getchar();
	}
	while(str>='0'&&str<='9')
	 x=x*10+str-'0',str=getchar();
	return x*f;
}
void MovE(int qwq)
{
	int i;
	for(i=1;i<=book[qwq].number-1;i++)
	 book[qwq].zhiyin[i]=book[qwq].zhiyin[i+1];
	return ;
}
void MovE1(int qwq)
{
	int i;
	for(i=1;i<=book1[qwq].number-1;i++)
	 book1[qwq].zhiyin[i]=book1[qwq].zhiyin[i+1];
	return ;
}

void unMovE(int qwq)
{
	int i;
	for(i=book[qwq].number;i>=1;i--)
	 book[qwq].zhiyin[i]=book[qwq].zhiyin[i-1];
	return ;
}
bool ChecK(int n,int SuM)
{
	int i,j;
	/*for(i=1;i<=n;i++)
	 book1[i]=book[i];
	for(i=1;i<=n;i++)
	{
		if(book[i].number<=0)
		 continue;
		for(j=1;j<=n;j++)
		{
			if(book[j].zhiyin[1]==book[i].zhiyin[1]&&i!=j)
			 MovE1(i),MovE1(j),book[i].number--,book[j].number--;
		}
	}*/
	for(i=1;i<=n;i++)
	 if(book[i].number>0)
	  return false;
	cout<<SuM<<endl;
	for(i=0;i<=SuM-1;i++)
	{
		cout<<bok[i][0]<<' ';
		if(bok[i][0]==1)
		 cout<<bok[i][1]<<endl;
		else
		 cout<<bok[i][1]<<' '<<bok[i][2]<<endl;
	}
	return true;
}
int Check_Yee(int n,int NoW)
{
	return 0;
	/*
	int i;
	for(i=1;i<=n;i++)
	 if(book[i].zhiyin[1]==book[NoW].zhiyin[1]&&book[NoW].number>=1&&book[i].number>=1&&i!=NoW)
	  */
}
void dfs(int n,int m,int NoW,int SuM)
{
	//cout<<"NOW:"<<NoW<<' ';
	bool noi=false,noip=false;
	if(NoW==m+1)
	{
		small_black=ChecK(n,SuM);
		return ;
	}
	int i,j;
	for(i=1;i<=n;i++)
	{
		if(book[i].number==0)
		{
			cout<<"1 NOW:"<<NoW<<endl;
			if(noi==true)
				continue;
			for(j=1;j<=n;j++)
			 if(book[j].zhiyin[1]==a[NoW]&&book[j].number!=0)
			  break;
			if(j==n+1)
				book[i].number=1,book[i].zhiyin[1]=a[NoW],bok[SuM][0]=1,bok[SuM][1]=i,dfs(n,m,NoW+1,SuM+1);
			else
				bok[SuM][0]=1,bok[SuM][1]=i,bok[SuM+1][0]=2,bok[SuM+1][1]=i,bok[SuM+1][2]=j,MovE(i),book[j].number--,dfs(n,m,NoW+1,SuM+2),book[j].number++,unMovE(i),book[j].zhiyin[1]=a[NoW];
			if(small_black==true)
			 return ;
			book[i].number=0,book[i].zhiyin[0]=0,noi=true;
		}
		else
		{
			cout<<"2 NOW:"<<NoW<<endl;
			if(book[i].zhiyin[book[i].number]==a[NoW])
			{
				book[i].number--;
				bok[NoW][0]=1,bok[NoW][1]=i;
				dfs(n,m,NoW+1,SuM+1);
				if(small_black==true)
				 return ;
				book[i].number++,book[i].zhiyin[book[i].number]=a[NoW];
			}
			else
			{
				book[i].number++,book[i].zhiyin[book[i].number]=a[NoW];
				bok[NoW][0]=1,bok[NoW][1]=i;
				dfs(n,m,NoW+1,SuM+1);
				if(small_black==true)
				 return ;
				book[i].number--;
			}
		}
		
	}
	return ;
}
int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int T,n,m,k,i,j;
	bool CoulD=false;
	T=readd();
	while(T--)
	{
		n=readd(),m=readd(),k=readd();
		for(i=1;i<=m;i++)
		 a[i]=readd();
		dfs(n,m,1,0);
		//if(small_black==false)
		// ChecK(n,15);
	}
	/*for(i=1;i<=n;i++)
	{
		cout<<book[i].number<<' ';
	 for(j=1;j<=book[i].number;j++)
	  cout<<book[i].zhiyin[j]<<' ';
	  cout<<endl;
	}*/
	fclose(stdin);
	fclose(stdout);
	return 0;
}