#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int main()
{
    int a;
    cin>>a;
    set<int > s1,c;
    set<int > s2;
    while (a--)
    {
        int t;
        cin>>t;
        s1.insert(t);
    }
    cin>>a;
    while (a--)
    {
        int t;
        cin>>t;
        s2.insert(t);
    }

    set_union(s1.cbegin(),s1.end(),s2.begin(),s2.end(),inserter(c,c.begin()));

    auto it=c.begin();
    auto its=c.end();
    for (auto i = it; i !=its ; ++i)
    {
        cout<<*i<<endl;
    }

}
