#include <bits/stdc++.h>
using namespace std;
int a[100005];
list<int >l;
int main (void)
{
int n,m,k,p;
cin>>n;l.push_back(1);
for(int i=2;i<=n;i++)
{ cin>>k>>p;
if (p) l.insert(++find(l.begin(), l.end(), k) , i); //在右边插入
else l.insert(find(l.begin(), l.end(), k), i ); //在左边插入
}int x;
cin>>m;
for(int i=1;i<=m;i++)
{
cin>>x;
a[x]=1;
}
for(list<int > ::iterator it=l.begin();it!=l.end();it++){
if(!a[*it]) cout<<*it<<" ";
}//输出
}