#include<bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define PF(i,a,b) for(int i=(a);i>=(b);--i)
#define Max(a,b) (((a)<(b)) and (a=b))
#define Min(a,b) (((a)>(b)) and (a=b))
#define ll long long
using namespace std;
bool beginning;
namespace solve {
	bool beginning;
	inline int read();
	const int N=2e6+5,M=305;
	int T,n,m,k,a[N];
	struct P {
		int b[M][M],l[M],r[M];
		P() {
			memset(b,0,sizeof(b));
			memset(l,0,sizeof(l));
			memset(r,0,sizeof(r));
		}
		inline void show() {
			puts("show===");
			F(i,1,n)cerr<<"l="<<l[i]<<" r="<<r[i]<<"\n";
			cerr<<'\n';
			F(i,1,n) {
				F(j,l[i]+1,r[i])cerr<<b[i][j]<<" ";
				cerr<<"\n";
			}
			puts("===");
		}
	};
	struct P2 {
		int x,s1,s2;
		P2(int a=0,int b=0,int c=0) {
			x=a,s1=b,s2=c;
		}
	} Stp[M*3];
	int check(P &now,int cnt,int &res) {
		int tmp=cnt;
		F(i,1,n) {
			if(now.l[i]==now.r[i])break;
			F(j,i+1,n) {
				if(now.l[j]==now.r[j])break;
				if(now.b[i][now.l[i]+1]==now.b[j][now.l[j]+1]) {
					++now.l[i],++now.l[j];
					res-=2;
					Stp[tmp++]=P2(2,i,j);
				}
			}
		}
		return tmp-cnt;
	}
	bool dfs(int x,P now,int cnt,int res) {
//	now.show();
//	cerr<<"x="<<x<<" cnt="<<cnt<<"\n";
		if(m-x+1<res) {
//			cerr<<"Res\n";
			return false;
		};
		if(x>m) {
//			F(i,1,n) {
//				if(now.l[i]<now.r[i])return false;
//			}
			printf("%d\n",cnt-1);
			F(i,1,cnt-1) {
				if(Stp[i].x==1)printf("%d %d\n",Stp[i].x,Stp[i].s1);
				else printf("%d %d %d\n",Stp[i].x,Stp[i].s1,Stp[i].s2);
			}
//		exit(0);
			return true;
		}
		bool flag=false;
		F(i,1,n) {
			if(i>=2 and now.r[i-1]==now.l[i-1])break;
			if(now.l[i]<now.r[i] and now.b[i][now.r[i]]==a[x]) { //放到 i 顶上并消去
				now.r[i]--;
				Stp[cnt]=P2(1,i);
//			cerr<<"in1\n"
				flag=dfs(x+1,now,cnt+1,res-1);
				if(flag)return true;
				now.r[i]++;
			} else { //放到 i 顶上，消不掉
//			cerr<<"in2\n";
				P cur=now;
				int rres=res+1;
				cur.b[i][++cur.r[i]]=a[x];
				Stp[cnt]=P2(1,i);
				int k=0,s=0;
				while(k=check(cur,cnt+1+s,rres))s+=k;

				flag=dfs(x+1,cur,cnt+1+s,rres);
//			cerr<<"out"<<"\n";
				if(flag)return true;
			}
		}
		return false;
	}
	bool ending;
	int main() {
//		cerr<<1.0*(&ending-&beginning)/1024/1024<<"MB\n";
//	freopen("","r",stdin);
//	freopen("","w",stdout);
		T=read();
		while(T--) {
			n=read(),m=read(),k=read();
			F(i,1,m)a[i]=read();
//		solve();
			P tmp;
			dfs(1,tmp,1,0);
		}
		return 0;
	}
	inline int read() {
		int x=0;
		bool f=1;
		char c=getchar();
		while(!isdigit(c))f=c^45,c=getchar();
		while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
		return f?x:-x;
	}
}
bool ending;
int main() {
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	solve::main();

	fclose(stdin);
	fclose(stdout);
	return 0;
}
