#include <bits/stdc++.h>
using namespace std;
int a[2000005];
int t[305],st[610];
// 1 down 2 up
struct ur {
	int op,fir,sed;
};
ur u;
vector <ur> apple;

inline int read(){
    register int s=0,w=1;
	char ch=getchar();
	while (ch<'0'||ch>'9'){
		if (ch=='-'){
			w*=(-1);
		}
		ch=getchar();
	}	
	while ('0'<=ch&&ch<='9'){
		s=s*10+ch-'0';
		ch=getchar();
	}
	return s*w;
}

inline void write (int x){
	register int cnt=0;
	char f[205];
	while(x){
		f[++cnt]=x%10+'0';
		x=x/10;
	}
	while (cnt){
		putchar(f[cnt--]);
	}
}

int main () {
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int q,n,m,k,i,ans=0,p;
	q=read();
	//if (q==1001||q==2) {
		while (q) {
			memset(t,0,sizeof(t));
			memset(st,0,sizeof(st));
			ans=0;
			n=read(),m=read(),k=read();
			for (i=1; i<=m; i++) {
				a[i]=read();
			}
			for (i=1; i<=m; i++) {
				if (a[i]>n-1) {
					p=a[i]-n+1;
				} else {
					p=a[i];
				}
				if (t[p]==0) {
					//cout<<"s1"<<" "<<p<<" "<<i<<endl;
					t[p]++;
					st[a[i]]=1;
					ans++;
					u.op=1;
					u.fir=p;
					apple.push_back(u);
				} else {
					if (st[a[i]]==0) {
						//cout<<"s2"<<" "<<p<<" "<<i<<endl;
						t[p]++;
						st[a[i]]=2;
						if (st[p+n-1]==2){
							st[p+n-1]=1;
						}
						ans++;
						u.op=1;
						u.fir=p;
						apple.push_back(u);
					} else {
						if (st[a[i]]==1) {
							//cout<<"s3"<<" "<<p<<" "<<i<<endl;
							t[p]--;
							st[a[i]]=0;
							ans+=2;
							u.op=1;
							u.fir=n;
							apple.push_back(u);
							u.op=2;
							u.fir=p;
							u.sed=n;
							apple.push_back(u);
						} else { 
							if (st[a[i]]==2) {
								//cout<<"s4"<<" "<<p<<" "<<i<<endl;
								t[p]--;
								st[a[i]]=0;
								ans++;
								u.op=1;
								u.fir=p;
								apple.push_back(u);
							}
						}
					}
				}
			}
			cout<<ans<<endl;
			for (i=0; i<ans; i++) {
				u=apple[i];
				write(u.op);
				if (u.op==1) {
					putchar(' ');
				    write(u.fir);
				    putchar('\n');
				} else {
					putchar(' ');
				    write(u.fir);
				    putchar(' ');
				    write(u.sed);
				    putchar('\n');
				}
			}
			q--;
			apple.clear();
		}
	//}
	return 0;
}
