#include using namespace std; //* ATCODER #include using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template T max(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template T min(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template T sum(vector &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } int main(){ int n; cin >> n; vector a(n-1), b(n-1); rep(i,0,n-1){ cin >> a[i] >> b[i]; a[i]--; b[i]--; } int m; cin >> m; vector v(m); vector obake(n); rep(i,0,m){ cin >> v[i]; v[i]--; obake[v[i]] = 1; } vector ikeru(n, vector(0)); rep(i,0,n-1){ ikeru[a[i]].push_back(b[i]); ikeru[b[i]].push_back(a[i]); } vector cnt(n); rep(i,0,n){ if (obake[i]){ cnt[i]++; for (int j: ikeru[i]){ cnt[j]++; } } } vector ans(n); vector less2(n); rep(i,0,n){ if (obake[i]){ for (int j: ikeru[i]){ if (cnt[j] < 2){ less2[i]++; } } } } int base = 0; rep(i,0,n){ if (cnt[i] > 0) base++; } rep(i,0,n){ if (obake[i]){ ans[i] += less2[i]; ans[i] += 1; for (int j: ikeru[i]){ if (obake[j]){ ans[i] += less2[j]; if (cnt[j] == 2){ ans[i] += 1; } } } }else{ int obakecount = 0; for (int j: ikeru[i]){ if (obake[j]){ obakecount++; ans[i] += less2[j]; if (cnt[j] == 1){ ans[i]++; } } } if (obakecount >= 2){ ans[i]++; } } cout << base - ans[i] << '\n'; } }