#include<bits/stdc++.h>
using namespace std;
int read() {
	int s=0; char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') s=(s<<1)+(s<<3)+c-'0',c=getchar();
	return s;
}
int n,m,k,a[100010];
int q[301][10001],h[301],t[301];
void solve() {
	n=read(); m=read(); k=read();
	for(int i=1;i<=m;i++) a[i]=read();
	if(n==1) {
		printf("%d\n",m);
		while(m--) {
			printf("1 1\n");
		}
		return;
	}
	if(n==2) {
		printf("%d\n",m);
		for(int i=1;i<=n;i++) {
			if(a[i]==1) {
				printf("1 1\n");
			}
			if(a[i]==2) {
				printf("1 2\n");
			}
		}
		return;
	}
}
int main() {
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int T; T=read();
	while(T--) solve();
	return 0;
}
