#include<bits/stdc++.h>
using namespace std;
int main(){
	#define int long long
	int n;
	cin>>n;
	vector<int> g[n+1];
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int a[n+1];
	for(int i=1;i<=n;i++) cin>>a[i];
	int q;
	cin>>q;
	if(q==0){
		int m = 100000000000000000;
		int ind = -1;
		for(int i=1;i<=n;i++){
			int distance[n+1]={};
			bool visited[n+1]={};
			queue<int> q;
			distance[i] = 0;
			q.push(i);
			while(!q.empty()){
				int x = q.front();
				q.pop();
				if(visited[x]) continue;
				visited[x] = true;
				for(auto u:g[x]){
					q.push(u);
					if(!visited[u]) distance[u] = distance[x]+1;
				}
			}
			int tr = 0;
			for(int j=1;j<=n;j++) tr+=distance[j]*a[j];
			if(tr<m){
				m = tr;
				ind = i;
			}
		}
		cout<<ind;
	}
}