#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<long long> vl;
typedef vector<vector<long long>> vvl;
typedef vector<vector<vector<long long>>> vvvl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound




int main(){

    int n,m;
    cin>>n>>m;

    vi a(n);
    vi b(m);
    rep(i,n) cin>>a[i];
    rep(i,m) cin>>b[i];

    vi check(1001,0);
    rep(i,n){
        check[a[i]]++;
    }   
    rep(i,m){
        check[b[i]]++;
    }
    
    for (int i=1; i<=1000; i++){
        if (check[i]==1) cout<<i<<" ";
    }
    cout<<endl;





}
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;
int num[1005];

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(a[i] == b[j]) num[a[i]] = 1;
            else{
                if(num[a[i]] != 1) num[a[i]] = 2;
                if(num[b[j]] != 1) num[b[j]] = 2;
            }
        }
    }
    vector<int> ans;
    for(int i = 1; i <= 1000; i++){
        if(num[i] == 2) ans.push_back(i);
    }
    if(ans.size() == 0){
        cout << "" << endl;
    }else{
        for(int i = 0; i < ans.size(); i++){
            cout << ans[i] << " ";
        }
        cout << endl;
    }
    return 0;
}