#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=300005;
int vis[N],cur=0;
int p[N],in[N];
vector<int>order;
vector<int>g[N],g2[N];
set<int>ng[N];
int comp[N];
vector<int>v[N];
bool loopcheck(int node)
{
    if(vis[node]==1)
        return 1;
    if(vis[node]==2)
        return 0;
    vis[node]=1;
    for(auto it:g[node])
    {
        if(loopcheck(it))
            return 1;
    }
    vis[node]=2;
    return 0;
}
void dfs(int node)
{
    if(vis[node])
        return ;
    comp[node]=cur;
    v[cur].push_back(node);
    vis[node]=1;
    for(auto it:g2[node])
        dfs(it);
}
bool topsort(int n)
{
    vector<int>indeg(n+1,0);
    queue<int>q;
    for(int i=1;i<=n;i++)
    {
        for(auto it:g[i])
            indeg[it]++;
    }
    for(int i=1;i<=n;i++)
        if(!indeg[i])
            q.push(i);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        order.push_back(u);
        for(auto it:g[u])
        {
            indeg[it]--;
            if(indeg[it]==0)
                q.push(it);
        }
    }
    if((int)order.size()<n)
        return false;
    return true;
}
int n,k;
void solve()
{
    cin>>n>>k;
    //cout<<n<<k<<"\n";
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
        if(p[i]!=0)
        {
            g[p[i]].push_back(i);
        }
        //cout<<i<<" "<<p[i]<<"\n";
    }
    for(int i=1;i<=k;i++)
    {
        int x,y;
        cin>>x>>y;
        in[y]++;//this cannot start in a component so dont start the component dfs from this
        g[x].push_back(y);
        g2[x].push_back(y);
    }
    /*for(int i=1;i<=n;i++)
    {
        cout<<i<<"\n";
        for(auto it:g[i])
            cout<<it<<" ";
        cout<<"\n";
    }*/
    bool hascycle=false;
    fill(vis,vis+n+1,0);
    for(int i=1;i<=n;i++)
    {
        if(!vis[i] && loopcheck(i))
        {
            hascycle=true;
            break;
        }
    }
    //cout<<hascycle<<"\n";
    if(hascycle)
    {
        cout<<"0\n";
        return;
    }
    fill(vis,vis+n+1,0);
    for(int i=1;i<=n;i++)
    {
        if(vis[i] || in[i])
            continue;
        cur++;
        dfs(i);
    }
    for(int i=1;i<=n;i++)
    {
        if(!p[i])
            continue;
        if(comp[p[i]]!=comp[i])
            ng[comp[p[i]]].insert(comp[i]);
    }
    for(int i=1;i<=n;i++)
        g[i].clear();
    for(int i=1;i<=cur;i++)
    {
        for(auto it:ng[i])
            g[i].push_back(it);
    }
    if(!topsort(cur))
        cout<<"0\n";
    else
    {
        for(auto it:order)
        {
            for(auto it1:v[it])
                cout<<it1<<" ";
        }
    }
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}