#include <bits/stdc++.h>
#define ll long long
#define MAXN 2010
#define INF 2000000000000000010

using namespace std;

ll N, L, R, Q, X, Y, rez, tren, mini = INF;
vector <ll> graf[MAXN];
vector <ll> dist(MAXN);
vector <ll> A(MAXN);

void BFS(int cvor)
{
    tren = 0;
    queue <ll> q;
    dist[cvor] = 0;
    q.push(cvor);
    while(q.size())
    {
        ll sad = q.front();
        q.pop();
        for(auto sled : graf[sad]) {if(dist[sled] == -1) {dist[sled] = dist[sad] + 1; q.push(sled); tren += dist[sled]*A[sled];}}
    }
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> N;
    for(int i = 0; i < N-1; i++)
    {
        cin >> X >> Y;
        graf[X].push_back(Y);
        graf[Y].push_back(X);
    }
    for(ll i = 1; i <= N; i++) cin >> A[i];
    cin >> Q;
    while(Q--) {cin >> L >> R;}
    for(ll i = 1; i <= N; i++)
    {
        for(ll i = 0; i < N+5; i++) dist[i] = -1;
        BFS(i);
        if(tren < mini) {mini = tren; rez = i;}
    }
    cout << rez << endl;
    return 0;
}