#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e6+1;

int n,m,i,j,t,k,cnt,cnt1,cnt2;
int s[305][N],a[N],p[610],book[305],resi[N],resj[N];

int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	scanf("%d",&t);
	while(t--){
		scanf("%d%d%d",&n,&m,&k);
		for(i=1;i<=m;++i)
		 scanf("%d",&a[i]);
		cnt=0;
		for(i=1;i<=m;++i){
			cnt++;if(cnt==n+1) cnt=1;
			if(i<=n) p[cnt]=a[i];
		}
		for(i=1;i<=k;++i){
			for(j=1;j<=k;j++){
				if(p[i]==p[j] && i!=j){
					resi[++cnt2]=i;
					resj[cnt2]=j;
				}
			}
		}
		cout<<m+cnt2<<endl;
		for(i=1;i<=m;++i){
			cnt++;if(cnt==n+1) cnt=1;
			printf("1 %d\n",cnt);
			if(i<=n) p[cnt]=a[i];
		}
		while(cnt2--){
			cout<<2<<resi[cnt2]<<" "<<resj[cnt2]<<endl;
		}
	}
	return 0;
}