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

int n;
int ans[100005];

struct slujitel{
    int val;
    slujitel* lc = nullptr;
    slujitel* rc = nullptr;

};

slujitel sl[100005];

void obhojdane(vector<int> obh, slujitel* curr){
 //   cout  << "cv " << curr->val << " ";
    for(auto i : obh) ans[i]++;
    obh.push_back(curr->val);
    if(curr->lc != nullptr) obhojdane(obh, curr->lc);
    if(curr->rc != nullptr) obhojdane(obh, curr->rc);
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);





    cin >> n;
    for(int i = 1; i <= n; i++){
        sl[i].val = i;
        //cout << "sl 3 val" << sl[i].val << " " << i<< "\n";
    }

    for(int i = 0; i < n-1; i++){
        int p, c;
        cin >> p >> c;
        ans[c] = 1;
        if(sl[p].lc == nullptr){
            sl[p].lc = &sl[c];
            //cout << p << " " << c << " " << sl[c].val << "\n";

        }else{
            sl[p].rc = &sl[c];
        }
    }

    int r = 0;
    for(int i = 1; i <=n; i++){
        if(ans[i] == 0){
            r = i;
        //    cout << "r " << r << "\n";
            ans[i] = 1;
        }
    }

    slujitel* root = &sl[r];

    vector<int> obh;
    obhojdane(obh, root);

    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int cq;
        cin >> cq;
        cout << ans[cq]-1 << "\n";
    }

    return 0;
}
