#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int B=400;


int N;
vint G[111111];

int who[3][111111];
int A[111111];


int par[111111],dep[111111];
void dfs(int v,int p,int d){
	par[v]=p;
	dep[v]=d;
	for(auto u:G[v]){
		if(u==p)continue;
		dfs(u,v,d+1);
	}
}


inline bool isok(int a,int b){
	rep(i,2){
		if(dep[a]<dep[b])swap(a,b);
		a=par[a];
		if(a==b)return true;
	}
	return false;
}

vint anslis;

void calc(int q){
	vint x(q);
	rep(i,q)scanf("%lld",&x[i]);

	memset(who,-1,sizeof(who));
	queue<pint>que;
	rep(i,q){
		if(who[0][x[i]]!=-1)continue;
		who[0][x[i]]=i;
		que.push(pint(0,x[i]));	
	}
	while(que.size()){
		int d,v;
		tie(d,v)=que.front();
		que.pop();
		if(d==2)continue;
		for(auto u:G[v]){
			if(who[d+1][u]!=-1)continue;
			who[d+1][u]=who[d][v];
			que.push(pint(d+1,u));
		}
	}
	rep(i,N){
		int k=1000000;
		rep(j,3)if(who[j][i]!=-1)chmin(k,who[j][i]);
		if(k==1000000)continue;
		if(x[k]==i)continue;
		A[x[k]]+=A[i];
		A[i]=0;
	}


	rep(i,q){
		for(int j=0;j<i;j++){
			if(x[j]!=x[i]&&isok(x[j],x[i])){
				A[x[i]]+=A[x[j]];
				A[x[j]]=0;
			}
		}
		anslis.pb(A[x[i]]);
	}
}

signed main(){
	scanf("%lld",&N);
	rep(i,N-1){
		int a,b;
		scanf("%lld%lld",&a,&b);
		G[a].pb(b);G[b].pb(a);
	}
	rep(i,N)scanf("%lld",&A[i]);

	dfs(0,-1,0);

	int Q;scanf("%lld",&Q);

	for(int i=0;i<Q;i+=B){
		calc(min(Q-i,B));
	}

	rep(i,Q){
		printf("%lld\n",anslis[i]);
	}
	return 0;
}