/*
k==2n-2 is very easy
let a stack always be empty
and each stack be at most 2 colors in different color
when add a color ,if it has been stack'top add it in it
if it has been stack's bottom ,add it in empty stack and chose them

k==2n-1
obviously,if we use the way in k=2n-1,we have to let at least one stack be empty
and when no stack be empty,there'll be 2n-1 kinds of colors 
at that time, it okey to add a color in the stack's top,but not to the bottom
than,i don't know how to deal with
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define wt(x) write(x),puts("")
inline int read(){
	int x=0,k=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') k=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	return x*k;
}
void write(int x){
	if(x<0){
		putchar('-');
		x=-x;
	}
	if(x>9){
		write(x/10);
	}
	putchar(x%10+'0');
	return ;
}
const int N=2e6+7,mod=998244353;
int n,m,tot,cnt,ans,k;
int a[N],st[301][100000],h[301],t[301];
struct lll{
	int opt,x,y;
}b[N];
void solve(){
	fo(i,1,n) st[i][0]=0,st[i][1]=0;
	fo(i,1,m){
		int p=(a[i]+1)/2;
		if(st[p][0]==a[i]){
			b[++tot]={1,n,0};
			b[++tot]={2,p,n};
			st[p][0]=st[p][1];
			st[p][1]=0;
		}
		else if(st[p][1]==a[i]){
			b[++tot]={1,p,0};
			st[p][1]=0;
		}
		else{
			b[++tot]={1,p,0};
			if(!st[p][0]) st[p][0]=a[i];
			else st[p][1]=a[i];
		}
	}
	wt(tot);
	fo(i,1,tot){
		if(b[i].opt==1){
			printf("%d %d\n",b[i].opt,b[i].x);
		}
		else{
			printf("%d %d %d\n",b[i].opt,b[i].x,b[i].y);
		}
	}
}
signed main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int tt=read();
	while(tt--){
		n=read();m=read();k=read();
		fo(i,1,m) a[i]=read();
		tot=0;
		if(k==2*n-2) {
			solve();
			continue;
		}
//		if()
	}
}
