#include<bits/stdc++.h>
using namespace std;

int vruh;
vector<int> a[100000];
bool k[100000];

int dfs(int z){
    if(k[z]){
        return 0;
    }
    int ans = 1;
    k[z] = true;
    for(auto i:a[z]){
        ans += dfs(i);
    }
    k[z] = false;
    return ans;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n-1; i++){
        int x,y;
        cin >> x >> y;
        a[x].push_back(y);
        k[y] = true;
    }
    for(int i = 1; i <= n; i++){
        if(!k[i]){
            vruh = i;
        }
        k[i] = false;
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int z;
        cin >> z;
        if(z == vruh){
            cout << n-1 << "\n";
            continue;
        }
        cout << dfs(z)-1 << "\n";
    }
    return 0;
}

