#include <bits/stdc++.h>
#define ll long long
#define rep(i,l,m) for(int i=l;i<=m;++i)
using namespace std;
inline void read(int &x) {
	int f=1;
	char ch=getchar();
	if(ch<'0'||ch>'9') {
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		x=(x<<3)+(x<<1)+ch-'0';
		ch=getchar();
	}
	x*=f;
	return ;
}
inline void write(int x) {
	if(x<0) {
		putchar('-');
		x=-x;
	}
	if(x>9) write(x/10);
	putchar(x%10+'0');
}
const int N=2e6+5;
int T,n,m,k;
int a[N];
int st[305][N>>1];
int cnt[N];
int ta[N];
bool flag;
int ans;
string s;
char c;
int x;
int main() {
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	ios::sync_with_stdio(0);
	read(T);
	while(T--) {
		ans=0;
		s="";
		read(n);
		read(m);
		read(k);
		rep(i,1,m) read(a[i]);
		rep(i,1,n)
		{
			cnt[i]=1;
			ta[i]=1;
		}
		rep(i,1,m)
		{
			rep(j,1,n)
			{
				if(st[j][cnt[j]]==a[i])
				{
					s+="1 ";
					c=j+'0';
					s+=c;
					s+='\n';
					ans++;
					flag=1;
					cnt[j]--;
					break;
				}
			}
			rep(j,1,n)
			{
				if(a[i]==0) break;
				if(cnt[j]-ta[j]+1>m/2) continue;
				st[j][cnt[j]]=a[i];
				s+="1 ";
				c=j+'0';
				s+=c;
				s+='\n';
				ans++;
				flag=1;
				cnt[j]++;break;
			}
			rep(i,1,n)
			{
				rep(j,i+1,n)
				{
					if(st[i][ta[i]]==st[j][ta[j]]&&(st[i][ta[i]]!=0&&st[j][ta[j]]!=0))
					{
						++ans;
						s+="2 ";
						c=i+'0';s+=c;s+=' ';
						c=j+'0';s+=c;s+='\n';
						ta[i]++;
						ta[j]++;
					}
				}
			}
		}
		cout<<ans<<"\n"<<s;	
	}
	//cout<<s<<"\n";
	return 0;
}