#include<bits/stdc++.h>
#define mk make_pair
#define I inline
#define RI register int
#define rep(i,a,b) for(RI i=a;i<=b;++i)
#define dow(i,a,b) for(RI i=a;i>=b;--i)
using namespace std;
const int N=2e6+5;
int T,n,k,m,top,lnk[N],vis1[N],vis2[N],vis[N],buk[N],to[N],a[N];
pair<int,int> st[N];
set<int> s1,s2;
bool flag[N];
I void solve1(){
	rep(i,1,m){
		if(vis[a[i]]){
			if(vis[a[i]]==1) st[++top]=mk(0,a[i]+1>>1);
			else st[++top]=mk(0,n),st[++top]=mk(a[i]+1>>1,n);
			vis[a[i]]=0;
		} else 
			st[++top]=mk(0,a[i]+1>>1),
			vis[a[i]]=vis[(a[i]+1^1)-1]?1:2;
	}
}
I void solve2(int x){
	if(x==m+1) return;
	if(vis1[a[x]]){
		st[++top]=mk(0,vis1[a[x]]);
		vis1[a[x]]=0,++n;
		return solve2(x+1);
	}
	if(n==1) return st[++top]=mk(0,1),solve2(x+1);
	RI y=to[x],mj=a[y-1];
	rep(i,x,y) vis[a[i]]^=1;
	rep(i,x,y) if(!vis[a[i]]) mj=a[i];
	lnk[mj]=lnk[a[x]]=vis1[a[x]]=vis2[mj]=1;
	st[++top]=mk(0,n);
	return solve2(x+1);
}
I void solve(){
	scanf("%d%d%d",&n,&m,&k);top=0;
	rep(i,1,m) scanf("%d",&a[i]);
	dow(i,n,1) to[i]=buk[a[i]],buk[a[i]]=i;
	solve1();
	printf("%d\n",top);
	rep(i,1,top){
		if(st[i].first==0) printf("1 %d\n",st[i].second);
		else printf("2 %d %d\n",st[i].first,st[i].second);
	}
}
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	scanf("%d",&T);
	while(T--) solve();
	return 0;
}