#include <bits/stdc++.h>

using namespace std;

using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using isize = ptrdiff_t;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using usize = size_t;

using f32 = float_t;
using f64 = double_t;

auto main() -> i32 {

    ios::sync_with_stdio(false), cin.tie(nullptr);

    usize n, m;
    cin >> n >> m;
    vector<usize> f(1000 + 1, 0);

    for (usize i = 0; i < n; i++) {
        usize a;
        cin >> a;
        f[a] = 1;
    }

    for (usize i = 0; i < m; i++) {
        usize b;
        cin >> b;
        f[b] = (f[b] + 1) % 2;
    }

    for (usize i = 0; i < 1000 + 1; i++) {
        if (f[i] == 1) {
            cout << i << " ";
        }
    }
    cout << "\n";
    return 0;
}
#include <bits/stdc++.h>

using namespace std;
    
//#define endl '\n'
#define pb push_back
#define ll long long
#define int ll
#define FF first
#define SS second
#define f(a,b,c) for(int a=b;a<=c;a++)
#define fd(a,b,c) for(int a=b;a>=c;a--)
#define fspr(X) fixed<<setprecision(X)

int mod = 1000000007;

ll mod_pow(ll x, ll n, ll m = mod) {
	if (n < 0) {
		ll res = mod_pow(x, -n, m);
		return mod_pow(res, m - 2, m);
	}
	if (abs(x) >= m)x %= m;
	if (x < 0)x += m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}

signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int T=1;//cin>>T;
   	while(T--)
    {
    	int n,m;cin>>n>>m;
    	int A[n],B[m];
    	f(i,0,n-1)cin>>A[i];f(i,0,m-1)cin>>B[i];
    	int i=0,j=0;
    	while(i<n || j<m){
    		if(i>=n){
    			while(j<m){
    				cout<<B[j]<<" ";j++;
				}
			}
			if(j>=m){
    			while(i<n){
    				cout<<A[i]<<" ";i++;
				}
			}
    		while(i<n && j<m && A[i]<B[j]){
    			cout<<A[i]<<" ";i++;
			}
			while(j<m && i<n && A[i]>B[j]){
				cout<<B[j]<<" ";j++;
			}
			while(i<n && j<m && A[i]==B[j]){
				i++;j++;
			}
		}
		cout<<endl;
    }
}