#include <bits/stdc++.h>
#define N 2010191
using namespace std;
int n,t,m,k,dt;
int a[N],ans[N][3];
vector<int> z[555],vis[1091];
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	scanf("%d",&t);
	int mn=0,mx=0,cnt;
	while(t--){
		mn=0,mx=0,cnt=1;
		scanf("%d%d%d",&n,&m,&k);
		for(int i=1;i<=m;++i){
			scanf("%d",&a[i]);
			vis[a[i]].clear();
		}
		printf("%d\n",m);
		for(int i=1;i<=m;++i){
			printf("1 %d\n",(i-1)%n+1);
		}
	}
	return 0;
}