#include<bits/stdc++.h>
using namespace std;
int tt[20];
int s1[20],s2[20];
int zhishi[10001];
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')
			f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	int t=read();
	while(t--){
		int ans=0;
		int n=read(),m=read(),k=read();
		for(int i=1;i<=m;++i) tt[i]=read();
		for(int i=1;i<=20;++i) s1[i]=0,s2[i]=0;
		int k1=0,k2=0;
		if(n==2){
			int i=1;
			while(i<=n){
				if(tt[i]==tt[i+1]){
					zhishi[++ans]=1;
					zhishi[++ans]=1;
					i+=1;
				}
				else if(tt[i]==s1[1]&&s2[1]==0){
					zhishi[++ans]=2;
					zhishi[++ans]=4;
				}
				else if(tt[i]==s2[1]&&s1[1]==0){
					zhishi[++ans]=1;
					zhishi[++ans]=4;
				}
				else{
					zhishi[++ans]=1;
					s1[++k1]=tt[i];
				}
				++i;
			}
			cout<<ans<<endl;
			for(int i=1;i<=ans;++i){
				if(zhishi[i]==1) cout<<1<<" "<<1<<endl;
				if(zhishi[i]==2) cout<<1<<" "<<2<<endl;
				if(zhishi[i]==4) cout<<2<<" "<<1<<" "<<2<<" "<<endl;
			}
		}
		else{
			for(int i=1;i<=34;++i){
				cout<<34<<endl;
				cout<<1<<" "<<1<<endl;
			}
		}
	}
	fclose(stdin);
	fclose(stdout);//no hurgry!
	return 0;
}