#include<bits/stdc++.h>
#define ll long long
template <typename T> void read(T &x){
	T sign=1,sum=0;
	char c=getchar();
	while (!isdigit(c)){
		if (c=='-'){
			sign=-1;
		}
		c=getchar();
	}
	while (isdigit(c)){
		sum=(sum<<1)+(sum<<3)+c-'0';
		c=getchar();
	}
	x=sign*sum;
}
int T;
int n;
int m;
const int N=305;
const int M=2e6+50;
int a[M];
int k;
int l[N],r[N];
std::vector<int> s[N];
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	read(T);
	while (T--){
		read(n),read(m),read(k);
		for (int i=1;i<=m;++i){
			read(a[i]);
		}
		for (int i=1;i<=n;++i){
			l[i]=r[i]=0;
		}
		if (k==2*n-2){
			printf("%d\n",2*m-3);
			for (int i=1;i<=m;++i){
				for (int j=1;j<=n;++j){
					if (l[j]!=0){
						if (r[j]==a[i]){
							printf("1 %d\n",j);
							r[j]=0;
							a[i]=0;
							break;
						}
						if (l[j]==a[i]){
							printf("1 %d\n",n);
							printf("2 %d %d\n",j,n);
							l[j]=r[j];
							r[j]=0;
							a[i]=0;
							break;
						}
					}
				}
				if (!a[i]){
					continue;
				}
				for (int j=1;j<=n;++j){
					if (!l[j]||!r[j]){
						if (l[j]==0){
							l[j]=a[i];
						}
						else{
							r[j]=a[i];
						}
						printf("1 %d\n",j);
						break;
					}
				}
			}
		}		
	}
}