#include<bits/stdc++.h>
#define ll long long
#define ve vector<ll>
#define pa pair<ll,ll>
#define pb push_back
#define rd read()
using namespace std;
const ll mod=1e9+7,N=1000005;
ll n,m,k,a[N],t,vis[N],i;
ll cnt[N],num[N],p[N][2];
ll ans1[N<<1],ans2[N<<1],ans;
inline ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<3)+(x<<1)+(c-48);
		c=getchar();
	}
	return f*x;
}
queue<ll>q;
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	t=rd;
	while(t--){
		n=rd,m=rd,k=rd;ans=0;
		for(i=1;i<n;i++)q.push(i);
		for(i=1;i<=m;i++){
			a[i]=rd;
		}
		ll q=n;
		for(i=1;i<=m;i++){
			ll x=0;
			if(num[a[i]]){
				num[a[i]]=0;
				for(int j=1;j<=n;j++){
					if(p[j][1]!=0){
						ans1[++ans]=j;
						ans2[++ans]=0;
						break;
					}
				}
				continue;
			}
			for(int j=1;j<=n-1;j++){
				if(vis[a[i]]){x=1;
					if(p[j][0]==a[i]){
						if(p[j][1]==0){
							ans1[++ans]=j;
							ans2[ans]=0;
						}else{
							ans1[++ans]=q;
							ans2[ans]=0;
							ans1[++ans]=j;
							ans2[ans]=q;
						}
						p[j][0]=p[j][1];
						p[j][1]=0;
						vis[a[i]]=0;
						break;
					}else if(p[j][1]==a[i]){
						p[j][1]=0;
						ans1[++ans]=j;
						ans2[ans]=0;
						vis[a[i]]=0;
						break;
					}
				}else{
					if(p[j][0]==0){
						ans1[++ans]=j;
						ans2[ans]=0;x=1;
						p[j][0]=a[i];
						vis[a[i]]=1;
						break;
					}else if(p[j][1]==0){
						ans1[++ans]=j;
						ans2[ans]=0;x=1;
						p[j][1]=a[i];
						vis[a[i]]=1;
						break;
					}
				}
			}
			if(!x){
				num[a[i]]=1;
				ans1[++ans]=rand()%n+1;
				ans2[ans]=0;
			}
		}
		printf("%lld\n",ans);
		for(i=1;i<=ans;i++){
			if(ans2[i]==0)printf("1 %lld\n",ans1[i]);
			else printf("2 %lld %lld\n",ans1[i],ans2[i]);
		}
	}
}
