while True:
try:
n1=int(input())
s1=list(map(int,input().split()))
n2=int(input())
s2=list(map(int,input().split()))
#s1.extend(s2)
print(''.join(map(str,sorted(list(set(s1+s2))))))
except:
break #include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n1,n2,j;
int s1[10000],s2[10000];
long long res[20000];
while(cin >> n1){
j=0;
for(int i=0;i<n1;i++){
cin >> s1[i];
res[j++]=s1[i];
}
cin >> n2;
for(int i=0;i<n2;i++){
cin >> s2[i];
res[j++]=s2[i];
}
sort(res,res+n1+n2);
for(int j=0;j<n1+n2;j++){
if(res[j]!=res[j+1])
cout << res[j];
}
cout << '\n';
}
return 0;
}