#include<bits/stdc++.h>
using namespace std;
int mst[100010][2],num,pe,tn,listleft,theright;
void brk(){
mst[mst[pe][0]][1]=mst[pe][1];
mst[mst[pe][1]][0]=mst[pe][0];
}
void sert(int tmp){
int trn=abs(tn-1);
mst[mst[pe][tn]][trn]=tmp;
mst[tmp][tn]=mst[pe][tn];
mst[tmp][trn]=pe;
mst[pe][tn]=tmp;
}
int main(){
cin>>num;
for(int i=2;i<=num;i++){
cin>>pe>>tn;
sert(i);
}
cin>>num;
for(int i=0;i<num;i++){
cin>>pe;
brk();
}
for(int i=1;i<=num;i++)
if(mst[i][0]==0){
listleft=i;
break;
}
if(listleft!=0)
cout<<listleft<<' ';
theright=mst[listleft][1];
while(mst[theright][1]!=0){
cout<<theright<<' ';
theright=mst[theright][1];
}
cout<<theright;
return 0;
}