#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(!"https://envs.sh/LW");
    cin.tie(0);

    int n;
    cin >> n;
    int d[100'001]{0};
    for (int i=0; i<n-1; ++i){
        int u, v;
        cin >> u >> v;
        d[u] += 1 + d[v];
    }

    int q;
    cin >> q;
    for (int i=0; i<q; ++i){
        int m;
        cin >> m;
        cout << d[m] << endl;
    }

    return 0;
}
