#include<bits/stdc++.h>
using namespace std;
vector<int> depths;
vector<int> parent;
void addDep(int u, int v) {
    parent[v] = u;
    if(depths[u] == -1) {
        if(depths[v] == -1) {
            depths[v] = 0;
            depths[u] = 0;
        } else {
            depths[u] = depths[v];
        }
    } else {
        if(depths[v] == -1) {
            depths[v] = 0;
        } else {
            depths[u] += depths[v];
        }
    }
    depths[u]++;
    int a = u;
    while(parent[a] != -1) {
        a = parent[a];
        depths[a]++;
    }

    //cout << depths[u] << " " << depths[v] << endl;
}

int main() {
    int n;
    cin >> n;
    depths.resize(n + 1);
    parent.resize(n + 1);
    for(int i = 1; i < n + 1; i++) {
        depths[i] = -1;
        parent[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 << depths[a] << endl;
    }



    return 0;
}

