#include using namespace std::literals::string_literals; using i64 = long long; using std::cout; using std::endl; using std::cin; template std::vector make_v(size_t a){return std::vector(a);} template auto make_v(size_t a,Ts... ts){ return std::vector(ts...))>(a,make_v(ts...)); } int main() { int n; scanf("%d", &n); assert(2 <= n and n <= (int)1e5); std::vector> g(n); for(int i = 0; i < n - 1; i++) { int a, b; scanf("%d%d", &a, &b); assert(0 <= a and a < n); assert(0 <= b and b < n); g[a].insert(b); g[b].insert(a); } std::vector a(n); for(int i = 0; i < n; i++) { scanf("%d", &a[i]); assert(0 <= a[i] and a[i] <= (int)1e5); } int q; scanf("%d", &q); assert(1 <= q and q <= (int)1e5); while(q--) { int v; scanf("%d", &v); assert(0 <= v and v < n); for(auto e: g[v]) { a[v] += a[e]; a[e] = 0; g[e].insert(v); } g[v].clear(); printf("%lld\n", a[v]); } return 0; }