#include<iostream>
using namespace std;
struct link{
int pre;
int next;
link():pre(0),next(0){}
};
int main(){
int n,head;
cin>>n;
if(n==1){
int m;
cin>>m;
while(m--){
int temp;
cin>>temp;
if(temp==1)return 0;
}
cout<<1;
return 0;
}
link a[n+1];
head=1;
for(int i=2;i<=n;i++){
int stu,p;
cin>>stu>>p;
if(p==0){
if(a[stu].pre!=0){
a[i].pre=a[stu].pre;
a[a[stu].pre].next=i;
}
else {
head=i;
}
a[stu].pre=i;
a[i].next=stu;
}
else {
if(a[stu].next!=0){
a[i].next=a[stu].next;
a[a[stu].next].pre=i;
}
a[stu].next=i;
a[i].pre=stu;
}
}
int m;
cin>>m;
while(m--){
int temp;
cin>>temp;
a[a[temp].pre].next=a[temp].next;
a[temp].pre=a[temp].next=-1;
}
while(head!=0){
cout<<head<<" ";
head=a[head].next;
}
return 0;
}