#include<iostream>
#include<vector>

using namespace std;

int brBossOf[100000];
vector<int> bossOf[100000];

int func(int s) {
	if (brBossOf[s] != 0) return brBossOf[s];

	for (int i = 0; i < bossOf[s].size(); i++) {
		brBossOf[s] += (1 + func(bossOf[s][i]));
	}
	return brBossOf[s];
}

int main() {
	int n,q;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		bossOf[u].push_back(v);
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		int m;
		cin >> m;
		cout << func(m - 1) << endl;
	}
	return 0;
}