#include <iostream>
#include <vector>
using namespace std;
const int MAXN = 1e5 + 1;
vector<int> kids[MAXN];
int parent[MAXN];
int ans[MAXN];
int calc(int now){
    for (auto curr : kids[now]) {
        ans[now] += calc(curr) + 1;
    }
    return ans[now];
}
int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int root;
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        kids[a].push_back(b);
        parent[b] = a;
    }
    for (int i = 1; i <= n; i++) {
        if (parent[i] == 0) {
            root = i;
            break;
        }
    }
    calc(root);
    int q;
    cin >> q;
    while (q --> 0) {
        int p;
        cin >> p;
        cout << ans[p] << '\n';
    }
    return 0;
}
