#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>

using namespace std;

int main() {
	int N, M;
	int state[1000];
	cin >> N >> M;
	for (int i = 0; i < 1000;i++) {
		state[i] = 0;
	}
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		state[A - 1] += 1;
	}
	for (int i = 0; i < M; i++) {
		int B;
		cin >> B;
		state[B - 1] += 1;
	}
	for (int i = 0; i < 1000; i++) {
		if (state[i] == 1) {
			cout << i + 1 << " ";
		}
	}
}
#include<bits/stdc++.h>
#include<iostream>
#include<set>
#include<map>
#include<iterator>
#define ll              long long
#define lli             long long int
#define pb              push_back
#define mp              make_pair
#define RIP(i,n)        for(ll i=0; i<n; i++)
#define F(i,a,b)        for(int i=a; i<b; i++)
#define RIP1(i,n)       for(int i=(n-1); i>=0; i--)
#define FOR(i,a,b)      for(int i=a;i<(b); i++)
#define FOR1(i,a,b)     for(int i=a; i>=(b); i--)
#define sc(a)           scanf("%lld",&a)
#define SC(a)           scanf("%d",&a)
#define cin(a)          cin >> a
#define cout(a)         cout << a
#define pi              acos(-1)
#define pr(a)           printf("%lld\n",a)
#define PR(a)           printf("%lld ",a)
#define s(a,b)          sort(a,b)
#define sz(x)           (int)(x).size()
#define nl              '\n'
#define Max             10000
#define mod             1e9+7
using namespace std;
void F_I_O()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
ll gcd(ll a,ll b)
{
    if(b==0)
    {
        return a;
    }
    else
    {
        return gcd(b,a%b);
    }
}
int main()
{
    ll n,m;
    cin >> n >> m;
    vector<ll>a(n),b(m);
    vector<ll>cnt_a(Max,0),cnt_b(Max,0);
    vector<ll>ans;
    RIP(i,n)
    {
        cin >> a[i];
        cnt_a[a[i]]++;
    }
    RIP(i,m)
    {
        cin >> b[i];
        cnt_a[b[i]]++;
    }
    RIP(i,n)
    {
        if(cnt_a[a[i]]==1)
        {
            ans.pb(a[i]);
        }
    }
    RIP(i,m)
    {
         if(cnt_a[b[i]]==1)
        {
            ans.pb(b[i]);
        }
    }
    sort(ans.begin(),ans.end());
    RIP(i,ans.size())
    {
        cout << ans[i] << ' ';
    }
    cout << nl;
 /* ll a,b,c;
    cin >> a >> b >> c;
    double p = (b*c)/a*1.0;
    ll r = p;

    if(b%a==0 || c%a==0)
    {
        p--;
    }
    cout << max(p,0LL) << nl;*/
   /* ll a,b;
    cin >> a >> b;
    ll ans=1;
    for(ll i=2; i<=a; i++)
    {
       ll r = a/i + !(a%i==0);
        ll p = r*i;
        ll q = (r+1)*i;
        if(p<b && q<=b)
        {
            ans = max(ans,i);
        }
    }
    cout << ans << nl;*/
}

