#include <iostream>
#include <map>
#include <vector>

using namespace std;
map <int, vector <int>> office;
map <int, int> results;
int N, a, b, i, s;

void solve(int a) {

    for (auto guy:office[a]) {
        s++;
        if (results[guy]) {
            s += results[guy];
        }
        else {
            int previous_sum = s;
            solve(guy);
            results[guy] = s - previous_sum;
        }
    }
}

int main() {
    cin >> N;
    for (i = 1; i < N; i++) {
        cin >> a >> b;
        office[a].push_back(b);
    }
    cin >> N;
    for (i=0; i < N; i++) {
        cin >> a;
        s = 0;
        solve(a);
        results[a] = s;
        cout << s << endl;
    }
    return 0;
}
