#include<iostream>
#include<vector>

using namespace std;

int unsolvedSubs[100001];
int bossedBy[100001];
int brBossOf[100001];
vector<int> bossOf[100001];
int topBoss;

int func(int s) {
    if (brBossOf[s] != 0) return brBossOf[s];
    int boss = bossedBy[s];
    if (unsolvedSubs[boss] && brBossOf[boss] != 0) {
        brBossOf[s] = brBossOf[boss]-1;
        for (int i = 0; i < bossOf[boss].size(); i++) {
            if (bossOf[boss][i] == s) continue;
            brBossOf[s] -= brBossOf[bossOf[boss][i]] + 1;
        }
        return brBossOf[s];
    }

    for (int i = 0; i < bossOf[s].size(); i++) {
        brBossOf[s] += (1 + func(bossOf[s][i]));
    }
    unsolvedSubs[boss]--;
    return brBossOf[s];
}

int main() {
    int n, q;
    cin >> n;
    for (int i = 1; i <= n - 1; i++) {
        int u, v;
        cin >> u >> v;
        bossOf[u].push_back(v);
        unsolvedSubs[u]++;
        bossedBy[v] = u;
    }
    for (int i = 1; i <= n; i++) {
        if (brBossOf[i] == 0) {
            brBossOf[i] = n - 1;
            topBoss = i;
            break;
        }
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        int m;
        cin >> m;
        cout << func(m) << endl;
    }
    return 0;
}