#include<iostream>
#include<vector>
using namespace std;
const int MAXN = 1e5+7;
bool roditel[MAXN];
vector<int> susedi[MAXN];
int koren;
int brdeca[MAXN];
int f(int vr){
    if(brdeca[vr]!=0){
        return brdeca[vr];
    }
    if(susedi[vr].size()==0){
        return 0;
    }
    int a = 0;
    for(auto to:susedi[vr]){
        f(to);
        a+=brdeca[to];
    }
    brdeca[vr]=a+susedi[vr].size();
    return brdeca[vr];
}
int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin>>n;
    int x,y;
    for(int i=0;i<n-1;i++){
        cin>>x>>y;
        susedi[x].push_back(y);
        roditel[y]=true;
    }
    for(int i=1;i<=n;i++){
        if(!roditel[i]){
            koren=i;
        }
    }
    f(koren);
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>x;
        cout<<brdeca[x]<<"\n";
    }
    return 0;
}
