#include<bits/stdc++.h>
#define int long long 
using namespace std;
int T;
int mm[100005];
signed main(){
	freopen("moew.in","r",stdin);
	freopen("moew.out","w",stdout);
	cin>>T;
	while(T--){
		int n,m,k;
		int aa1=0;
		int aa2=0;
		cin>>n>>m>>k;
		if(n>=k){
			cout<<k;
			int kk[k];
			for(int i=1;i<=m;i++){
				cin>>mm[i];
				kk[mm[i]]++;
			}
			for(int i=1;i<=n;i++){
				if(kk[i]==0) break;
				for(int j=i;j<=kk[i];j++){
					cout<<j<<endl;
				}
			}
		}
		if(k!=2) cout<<"1026";
		for(int i=1;i<=n;i++){
			cin>>mm[i];
			if(mm[i]==1) aa1++;
			else (mm[i]==2) aa2++;
		}
	}
	return 0;
}
//ºÃÒ®----Þ±¹ÅË¿ 
