#include<bits/stdc++.h>
using namespace std;

vector<int> edges[100005], reverseEdges[100005], roots;
int ans[100005], c[100005];

void dfs(int i) {
    if(edges[i].size() == 0) ans[i] = 0;
    for(auto c : edges[i]) {
        dfs(c);
        ans[i] += ans[c] + 1;
    }
}

int findRoot(int i) {
    if(reverseEdges[i].size() == 0) return i;

    for(auto c : reverseEdges[i]) {
        return findRoot(c);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin>>n;
    for(int i = 0; i < n-1; i++) {
        int u, v;
        cin>>u>>v;
        edges[u].push_back(v);
        reverseEdges[v].push_back(u);
    }

    int m;
    cin>>m;
    for(int i = 0; i < m; i++) {
        cin>>c[i];
        int root = findRoot(c[i]);
        bool b = true;
        for(auto k : roots) {
            if(k == root) {
                b = false;
                break;
            }
        }
        if(b) roots.push_back(root);
    }

    for(auto k : roots) {
        dfs(k);
    }

    for(int i = 0; i < m; i++) {
        cout<<ans[c[i]]<<endl;
    }



    return 0;
}
