#include<stdio.h>
int mearge(inta, int lena, int*b, int lenb){
int*tmp=(int*)malloc(sizeof(int)*(lena+lenb));
for (int i=0; i<lena; i++){
tmp[i] = a[i];
}
for(int i=0; i<lenb; i++){
tmp[i+lena]=b[i];
}
free(a);
free(b);
return tmp;
}
int cmp (const void * a, const void * b)
{ return ( (int)a - (int)b ); }
int main(){
int number1;
while(scanf("%d", &number1) != EOF){
int number2;
int *a = (int*)malloc(sizeof(int)*number1);
for(int i=0; i<number1; i++){
scanf("%d", &a[i]);
}
scanf("%d", &number2);
int *b = (int*)malloc(sizeof(int)*number2);
for(int i=0; i<number2; i++){
scanf("%d", &b[i]);
}
int *new = mearge(a, number1 ,b ,number2);
qsort(new, number1+number2, sizeof(int), cmp);
for(int i=0; i<number1+number2; i++){
if(i>0 && new[i] == new[i-1])continue;
printf("%d", new[i]);
}
printf("\n");
}
}