#include <bits/stdc++.h>

using namespace std;

int main()
{
    
    vector<int> A, B;
    vector<int> Ans;
    
    int N, M, Num;
    
    cin >> N;
    A.resize(N);
    for(int i = 0; i < N; ++i)
        cin >> A[i];
        
    cin >> M;
    B.resize(M);
    for(int i = 0; i < M; ++i)
        cin >> B[i];
        
    set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(Ans, end(Ans)));
    
    for(const int &x : Ans)
      cout << x << endl;
    
    return 0;
}
