#include<bits/stdc++.h>
#define fori(i,a,b) for(i=a;i<=b;i++)
#define ford(i,a,b) for(i=a;i>=b;i--)
typedef long long ll;
typedef double db;
using namespace std;
const int N=2000;
const int M=1e6+5;
ll T,n,m,k,i,cnt,r[N],l[N],s[N][N],x,xx,w1[M],w2[M],w3[M];
int main()
{
	freopen("meow.in","r",stdin); freopen("meow.out","w",stdout);
	cin>>T;
	while (T--)
	{
		cin>>n>>m>>k;
		cnt=0;
		fori(i,1,n)
		{
			r[i]=0;
			l[i]=1;
		}
		fori(i,1,m) 
		{
			scanf("%lld",&x);
			xx=(x+1)/2;
			if (r[xx]<l[xx])
			{
				r[xx]++;
				s[xx][r[xx]]=x;
				cnt++;
				w1[cnt]=1; w2[cnt]=xx;
			} else {
				if (x==s[xx][r[xx]])
				{
					r[xx]--;
					cnt++;
					w1[cnt]=1; w2[cnt]=xx;
				} else 
				{
					if (x==s[xx][l[xx]])
					{
						l[xx]++;
						cnt++;
						w1[cnt]=1; w2[cnt]=n;
						cnt++;
						w1[cnt]=2; w2[cnt]=xx; w3[cnt]=n;
					} else {
						cnt++;
						r[xx]++;
			        	s[xx][r[xx]]=x;
			        	w1[cnt]=1; w2[cnt]=xx;
					}
				}
			}
		}
		cout<<cnt<<endl;
	fori(i,1,cnt)
	if (w1[i]==1) printf("1 %lld\n",w2[i]);
	else printf("2 %lld %lld\n",w2[i],w3[i]);
	}
	
}