#include <bits/stdc++.h>
using namespace std;
int const M=4e6+10,N=310;
int T,n,m,k,v,sa[N][3],st[N],ed[N],mea[M],meb[M],mec[M],cnt;
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>T;
	if(T%10==1)
	{
		while(T--){
			cnt=0;
			memset(sa,0,sizeof(sa));
			memset(st,0,sizeof(st));
			memset(ed,0,sizeof(ed));
			memset(mea,0,sizeof(mea));
			memset(meb,0,sizeof(meb));
			memset(mec,0,sizeof(mec));
			cin>>n>>m>>k;
			for(int i=1;i<=m;i++)
			{
				cin>>v; 
				int id=(v+1)/2;
				if(!sa[id][1]) {
					sa[id][1]=v;	
					cnt++;
					mea[cnt]=1;
					meb[cnt]=id;
				}
				else {
					if(sa[id][1]==v) {//下下消 
						cnt++;
						mea[cnt]=1;
						meb[cnt]=n;
						cnt++;
						mea[cnt]=2;
						meb[cnt]=id;
						mec[cnt]=n;
						sa[id][1]=sa[id][2];
						sa[id][2]=0;
					}
					else if(!sa[id][2]) {
							 sa[id][2]=v;	
							 cnt++;
							 mea[cnt]=1;
							 meb[cnt]=id;
							}
					else
						if(sa[id][2]==v){
							cnt++;
							mea[cnt]=1;
							meb[cnt]=id;
							sa[id][2]=0;
						}
				}	
			}
			cout<<cnt<<"\n";
			for(int i=1;i<=cnt;i++)
				if(mea[i]==1) cout<<mea[i]<<" "<<meb[i]<<"\n";
				else cout<<mea[i]<<" "<<meb[i]<<" "<<mec[i]<<"\n";
		}
	}
	else {
		while(T--){
			cnt=0;
			memset(sa,0,sizeof(sa));
			memset(st,0,sizeof(st));
			memset(ed,0,sizeof(ed));
			memset(mea,0,sizeof(mea));
			memset(meb,0,sizeof(meb));
			memset(mec,0,sizeof(mec));
			cin>>n>>m>>k;
			int flag=0,ff=0;
			for(int i=1;i<=m;i++)
			{
				cin>>v; 
				int id=(v+1)/2;
				if(id==n) {
					if(ff==0) {
						cnt++;
						flag=cnt;
						mea[cnt]=1;
						meb[cnt]=n;
					}
					else {
						cnt++;
						flag=0;
						mea[cnt]=1;
						meb[cnt]=ff;
					}
				}
				if(id!=n){
					if(!sa[id][1]) {//当前为空 
						sa[id][1]=v;	
						cnt++;
						mea[cnt]=1;
						meb[cnt]=id;
					}
					else {
						if(sa[id][1]==v&&sa[id][2]==0){
							if(ff!=0){
								cnt++;
								mea[cnt]=1;
								meb[cnt]=n;
								cnt++;
								mea[cnt]=2;
								meb[cnt]=id;
								mec[cnt]=n;
								sa[id][1]=sa[id][2];
								sa[id][2]=0;
							}
							else {
								cnt++;
								mea[cnt]=1;
								meb[cnt]=id;
								sa[id][1]=0;
							}
						}
						else if(sa[id][1]==v&&sa[id][2]){//下下消 
							if(flag==0){
								cnt++;
								mea[cnt]=1;
								meb[cnt]=n;
								cnt++;
								mea[cnt]=2;
								meb[cnt]=id;
								mec[cnt]=n;
								sa[id][1]=sa[id][2];
								sa[id][2]=0;
							}
							else{//n栈上有第2n-1种 
								mea[flag]=1;
								meb[flag]=id;
								ff=id;
								cnt++;
								mea[cnt]=1;
								meb[cnt]=n;
								cnt++;
								mea[cnt]=2;
								meb[cnt]=id;
								mec[cnt]=n;
								sa[id][1]=sa[id][2];
								sa[id][2]=0;
							} 
						}
						else if(sa[id][1]!=v &&sa[id][2]==0){
								cnt++;
								mea[cnt]=1;
								meb[cnt]=id;
								sa[id][2]=v;
							}
							else if(sa[id][1]!=v &&sa[id][2]){
									cnt++;
							mea[cnt]=1;
							meb[cnt]=id;
							sa[id][2]=0;
							}
					}
				}	
			}
			cout<<cnt<<"\n";
			for(int i=1;i<=cnt;i++)
				if(mea[i]==1) cout<<mea[i]<<" "<<meb[i]<<"\n";
				else cout<<mea[i]<<" "<<meb[i]<<" "<<mec[i]<<"\n";
		}
	}
	return 0;
}
