#include <bits/stdc++.h>
using namespace std;

void solve()
{
    int n, m; cin >> n >> m;
    unordered_set<int> a, b;

    int curr;
    for (int i = 0; i < n; ++i) {
        cin >> curr;
        a.insert(curr);
    }
    for (int i = 0; i < m; ++i) {
        cin >> curr;
        b.insert(curr);
    }
    set<int> ans;
    for (int num : a) {
        if (b.find(num) == b.end()) {
            ans.insert(num);
        }
    }
    for (int num : b) {
        if (a.find(num) == a.end()) {
            ans.insert(num);
        }
    }
    for (int num : ans) {
        cout << num << ' ';
    }
    cout << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
#include<bits/stdc++.h>
#define RT register
#define ll long long
#define ull unsigned long long
#define lowbit(x) (x&(-x))
using namespace std;

template<typename T>
inline void read(T &x){
    x=0; bool f=0;char ch=getchar();
    while(ch<'0'||ch>'9'){f|=ch=='-';ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    x=f?-x:x;
}
template<typename T>
inline void print(T x){
    if(x<0) x=-x,putchar('-');
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
const int N=1004;
int a[N],b[N];
int n,m;
int main(){
    read(n),read(m);
    for(int i=1;i<=n;i++) read(a[i]);
    for(int i=1;i<=m;i++) read(b[i]);
    a[n+1]=b[m+1]=100000;   
    for(int i=1,j=1;i<=n||j<=m;){
        if(a[i]<b[j]){
            print(a[i]),putchar(' ');i++;
        }
        else if(a[i]==b[j]){
            i++,j++;
        }
        else{
            print(b[j]),putchar(' ');j++;
        }
    }
    return 0;
}
