#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
long long read() {
	int f = 1;
	long long sum = 0;
	char c = getchar();
	while(!((c >= '0'&&c <= '9')||c == '-')) c = getchar();
	if(c == '-') f = -1,c = getchar();
	while(c >= '0'&&c <= '9') {
		sum = sum * 10 + c - '0';
		c = getchar();
	}
	return sum * f;
}
int a[10000100],n,m,k;
int z[310][100010];
struct ZZNNYY{
	int high,top,down;
}zh[310]; 
struct p{
	int fi,se;
}print[15000100];
void pprint(int step){
	if(step == 0) {
		return;
	}
	bool f = false;
	for(int i = 1;i <= n-1;i++){
		if(f) break;
		for(int j = i+1;j <= n;j++){
			if(z[i][zh[i].down] == z[j][zh[j].down]&&z[i][zh[i].down] != 0){
				printf("2 %d %d\n",i,j);
				f = true;
				break;
			}
		}
	}
	pprint(step-1);
}
int main() {
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	long long T = read(),t;
	t = T;
	while(T--){
		n = read(),m = read(),k = read();
		long long ans = m + m / 2;
		for(int i = 1;i <= m;i++){
			a[i] = read();
		}
		long long s = 0;
		for(int i = 1;i <= m;i++){
			for(int j = 1;j <= n;j++){
				if(zh[j].high == 0) {
					zh[j].high = 1;
					zh[j].top = a[i];
					zh[j].down = 1;
					s++;
					print[s].fi = 1;
					print[s].se = j;
					break;
				}else {
			    	if(a[i] == z[j][zh[j].high]){
					    ans-=1;
					    s++;
					    print[s].fi = 1;
					    print[s].se = j;
					    z[j][zh[j].high] = 0;
						zh[j].high--;
						zh[j].top =  z[j][zh[j].high];
						if(zh[j].high == 0) zh[j].down = 0;
						break;
				    }
			    }
			}
		}
		printf("%lld\n",ans);
		for(int i = 1;i <= s;i++){
			printf("%d %d\n",print[i].fi,print[i].se);
		}
		pprint(ans - m);
		memset(print,0,sizeof(print));
	}
	return 0;
}