#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld  long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 3e5 + 9;
int p[N], n, k, id[N], color[N], timee[N], timer ;
bool vis[N], bad[N];
vector<int> v[N], cmp, g[N];
vector<vector<int> > seg;
//map<pair<int, int>, bool> is_edge;
void dfs(int node) {
    if(vis[node]) {
        cout << "0";
        exit(0);
    }
    timee[node] = ++timer;
    cmp.push_back(node);
    vis[node] = true;
    for(auto i : v[node])
        dfs(i);
}
void check_cycle(int node) {
    color[node] = 1;

    for (int i : g[node]) {
        if (color[i] == 0) {
            check_cycle(i);
        } else if (color[i] == 1) {
            cout << "0";
            exit(0);
        }
    }
    color[node] = 2;
}
vector<int> id_orders;
void solve(int node) {

    vis[node] = true;
    for (int i : g[node]) {
        if (!vis[i])
            solve(i);
    }
    id_orders.push_back(node);
}
int main() {

    IO
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> p[i];
    while(k--) {
        int x, y;
        cin >> x >> y;
        bad[y] = true;
        v[x].push_back(y);
    }
    for(int i = 0; i <= n; i++)
        if(!vis[i] && !bad[i]) {
            cmp.clear();
            dfs(i);

            for(auto j : cmp)
                id[j] = seg.size();

            seg.push_back(cmp);
        }


    for(int i = 1; i <= n; i++) {
        int x = id[i], y = id[p[i]];
        // if(is_edge[ {x, y}])
        // continue;
        // is_edge[ {x, y}] = true;
        // cout<<x<<" "<<y<<"\n";
        if(x == y) {
            if(timee[i] < timee[p[i]]) {
                cout << "0";
                exit(0);
            }
            continue;
        }
        g[x].push_back(y);
    }

    for(int i = 0; i < seg.size(); i++) {
        if(color[i] == 0)
            check_cycle(i);
    }


    memset(vis, 0, sizeof vis);
    for(int i = 0; i < seg.size(); i++)
        if(vis[i] == 0)
            solve(i);
    for(auto i : id_orders) {
        for(auto j : seg[i])
            if(j)
                cout << j << " ";
    }
}
