#include<iostream>
#include<queue>
using namespace std;
const int MAX_N = 100000;
int podchineni[MAX_N];
bool hasParent[MAX_N];
//int parent[MAX_N];
int n, q;
vector<int> tr[MAX_N];
//queue<int> obh;
//bool putInQueue[MAX_N];
void calculate(int vr)
{
    if(tr[vr].empty())
    {
        podchineni[vr] = 0;
        return;
    }
    for(int i = 0; i < tr[vr].size(); i++)
    {
        calculate(tr[vr][i]);
        podchineni[vr] += podchineni[tr[vr][i]] + 1;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    /*for(int i = 0; i < n; i++)
    {
        parent[i] = -1;
    }*/
    for(int i = 0; i < n - 1; i++)
    {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        tr[u].push_back(v);
        hasParent[v] = true;
        //parent[v] = u;
    }
    /*for(int i = 0; i < n; i++)
    {
        if(tr[i].empty())
        {
            obh.push(i);
            putInQueue[i] = true;
        }
    }
    while(!obh.empty())
    {
        int currV = obh.front();
        obh.pop();
        if(hasChildren[currV])
        {
            for(int i = 0; i < tr[currV].size(); i++)
            {
                int child = tr[currV][i];
                podchineni[currV] += podchineni[child] + 1;
            }
        }
        if(parent[currV] == -1)
        {
            break;
        }
        podchineni[parent[currV]] += podchineni[currV] + 1;
        if(!putInQueue[parent[currV]])
        {
            obh.push(parent[currV]);
        }
    }*/
    int root;
    for(int i = 0; i < n; i++)
    {
        if(!hasParent[i])
        {
            root = i;
            break;
        }
    }
    calculate(root);
    cin >> q;
    for(int i = 0; i < q; i++)
    {
        int query;
        cin >> query;
        query--;
        cout << podchineni[query] << endl;
    }
    return 0;
}
/*
6
1 2
2 3
2 4
4 5
4 6
6
1
2
3
4
5
6
*/
