#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define endl "\n"
#define __WaffledCookies__ signed main
using namespace std;

const int N = 2e5 + 5, mod = 1e9 + 7, base = 167;
int tc, n, m;
bool a[105];
void solve()
{
    cin >> n >> m;
    for(int i = 1; i <= n; ++i) {
        int tp;
        cin >> tp;
        a[tp] = 1;
    }
    for(int i = 1; i<= m; ++i) {
        int x, y;
        cin >> x >> y;
        a[x] = 0;
        a[y] = 1;
    }
    for(int i = 1; i <= 100; ++i) if(a[i]) cout << i << ' ';
    return;
}
__WaffledCookies__()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    tc = 1;
    //cin >> tc;
    while(tc--) solve();
    return 0;
}
