#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> t;
vector<int> depths;
void addDep(int u, int v) {
    t[u].push_back(v);
}

int dfs(int curr) {
    if(depths[curr] != -1) return depths[curr];
    int res = t[curr].size();
    for(auto i : t[curr]) {
        if(depths[i] != -1) {
            res += depths[i];
        } else {
            res += dfs(i);
        }
    }
    if(depths[curr] == -1) {
        depths[curr] = res;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    t.resize(n + 1);
    depths.resize(n + 1);
    for(int i = 1; i < n + 1; i++) {
        depths[i] = -1;
    }
    for(int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        addDep(u, v);
    }
    int q;
    cin >> q;
    while(q--) {
        int a;
        cin >> a;
        cout << dfs(a) << endl;
    }



    return 0;
}

