#include<iostream>
#include<vector>

using namespace std;

int n,q;
int brBossOf[100001];
int bossedBy[100001];
vector<int> bossOf[100001];

int func(int s) {
	if (brBossOf[s] != 0) return brBossOf[s];
	if (bossedBy[s] == 0) return (n - 1);

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

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