#include<iostream>
#include<vector>
#include<queue>
using namespace std;

int brVurhove, brRebra, q;
vector<int> decaNa[100001];
queue<int> susediZaObhojdane;
int ans[100001];
int brVlizashti [100001];
int zaqvki [100001];

void bfs(int startVruh){
    susediZaObhojdane.push(startVruh);

    while(!susediZaObhojdane.empty()){
        int tekVruh = susediZaObhojdane.front();
        susediZaObhojdane.pop();
        for(int i = 0 ; i < decaNa[tekVruh].size() ; i++){
            ans [tekVruh] += ans [decaNa[tekVruh][i]];
            susediZaObhojdane.push(decaNa[tekVruh][i]);
        }
    }
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> brVurhove;
    brRebra = brVurhove - 1;

    int a, b ;
    for(int i = 0 ; i < brRebra ; i ++){
        cin >> a >> b;
        decaNa[a].push_back(b);
        brVlizashti[b] ++ ;
    }
    for(int i = 1 ; i <= brVurhove ; i ++){
        ans [i] = decaNa[i].size();
    }

    for(int i = 1 ; i <= brVurhove ; i ++){
        if(brVlizashti[i] == 0){
            bfs(i);
            break;
        }
    }


    cin >> q;
    for(int i = 0 ; i < q ; i ++){
        cin >> zaqvki [i] ;
        cout << ans [zaqvki [i]] << endl ;
    }

    return 0;
}
