#include<bits/stdc++.h>
using namespace std;
int n,q,m[100004];
vector<int> adj[100004];
int dp[100004];
int solve(int vr){
    if(vr<0||vr>=n){
        return 0;
    }
    else if(dp[vr]!=0){
        return dp[vr];
    }
    else if((int)adj[vr].size()==0){
        return 0;
    }
    else{
    for(int i=0;i<(int)adj[vr].size();i++){
        dp[vr]+=(1+solve(adj[vr][i]));
    }
    return dp[vr];
    }
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("test.txt","r",stdin);
memset(dp,0,sizeof(dp));
cin>>n;
int u,v;
for(int i=0;i<n-1;i++){
    cin>>u>>v;
    adj[u].push_back(v);
}
cin>>q;
for(int i=0;i<q;i++){
    cin>>m[i];
}
for(int i=0;i<q;i++){
    cout<<solve(m[i])<<"\n";
}
return 0;
}
