#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//读取元素后按照升序无重合并

int cmp_int(const void *a, const void *b);
int main()
{
  int n1, n2;
  while (scanf("%d", &n1) != EOF)
  {
    int s1[n1];
    for (int i = 0; i < n1; i++)
      scanf("%d", &s1[i]);
    scanf("%d", &n2);
    int s2[n2];
    for (int i = 0; i < n2; i++)
      scanf("%d", &s2[i]);
    int s[n1 + n2];
    int top = -1;
    int flag = 0; //0无重复
    for (int i = 0; i < n1; i++)
    {
      flag = 0;
      for (int j = 0; j <= top; j++)
      {
        if (s1[i] == s[j])
        {
          flag = 1;
          break;
        }
      }
      if (flag == 0)
        s[++top] = s1[i];
    }

    for (int i = 0; i < n2; i++)
    {
      flag = 0;
      for (int j = 0; j <= top; j++)
      {
        if (s2[i] == s[j])
        {
          flag = 1;
          break;
        }
      }
      if (flag == 0)
        s[++top] = s2[i];
    }

    //0-top sort
    qsort(s, top + 1, sizeof(s[0]), cmp_int);

    for (int i = 0; i <= top; i++)
    {
      printf("%d", s[i]);
    }
    printf("\n");
  }

  return 0;
}

int cmp_int(const void *a, const void *b)
{
  return *(int *)a - *(int *)b;
}