#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5+7;
vector<int>G[maxn];
int n,k,fa[maxn],nxt[maxn];
int L[maxn],id,rnk[maxn],vis[maxn],rt[maxn],R,ind[maxn];
int main() {
	cin>>n>>k;
	for (int i=1;i<=n;i++) {
		int x;cin>>x;
		fa[i]=x;
		if (x==0) R=i;
	}
	for (int i=1;i<=k;i++) {
		int x,y;
		cin>>x>>y;
		nxt[x]=y;
		vis[y]=1;
	}
	for (int i=1;i<=n;i++) {
		if (vis[i]) continue;
		L[i]=++id;
		int now=0,x=nxt[i];
		rnk[i]=now;
		rt[id]=i;
		while(x!=0&&L[x]==0) {
			L[x]=id;
			rnk[x]=++now;
			x=nxt[x];
		}
	}

	// check circle pass
	for (int i=1;i<=n;i++) {
		if (!L[i]) {
			cout<<"0"<<endl;
			return 0;
		}
		if (L[i]==L[fa[i]]&&rnk[i]<rnk[fa[i]]) {
			cout<<"0"<<endl;
			return 0;
		}
	}

	for (int i=1;i<=n;i++) {
		if (fa[i]==0)continue;
		if (L[fa[i]] != L[i]) {
			G[L[fa[i]]].push_back(L[i]);
			ind[L[i]]++;
		}
	}

	vector<int> ans;
	queue<int> Q;
	for (int i=1;i<=id;i++) {
		if (ind[i]==0) {
			Q.push(i);
		}
	}
	while(!Q.empty()) {
		int now = Q.front();
		Q.pop();
		ans.push_back(now);
		for (int i=0;i<G[now].size();i++) {
			int v = G[now][i];
			ind[v]--;
			if (ind[v]==0) {
				Q.push(v);
			}
		}
	}
	if (ans.size()==id) {
		// for (int i=0;i<ans.size();i++) {
		//     cout<<"---- " << ans[i]<< " " << rt[ans[i]] << endl;
		// }
		for (int i=0;i<ans.size();i++) {
			int now = rt[ans[i]];
			int ID = L[rt[ans[i]]];
			while(now&&ID==L[now]) {
				cout<<now<<" ";
				now=nxt[now];
			}
		}
		cout<<endl;
		return 0;
	}
	cout<<"0"<<endl;
}