#include <iostream>
#include <vector>
using namespace std;
vector<int> sub[100000];
int totalsubs[100000];
int subfinder(int g)
{
if(totalsubs[g]==0 and !sub[g].empty()){
    totalsubs[g]+=sub[g].size();
    for(auto l: sub[g])
    {
        if(totalsubs[l]!=0){totalsubs[g]+=totalsubs[l]; continue;}
        totalsubs[g]+=subfinder(l);
   } 
    }
    return totalsubs[g];

}
int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int a=0; a<n-1; a++)
    {
        int c,b;
        cin>>c>>b;
        sub[c].push_back(b);
          
       // top[b]=a;
    }
    int q;
    cin>>q;
    for(int i=0; i<q; i++)
    {
        int g;
        cin>>g;
        cout<<subfinder(g)<<endl;
    }


    return 0;
}
