#include <bits/stdc++.h>
#define FAST {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define FILES {freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);}
#define ll long long
#define ull unsigned long long
#define pqueue priority_queue
#define pb push_back
#define fi first
#define se second
#define ld long double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) (a).begin(), (a).end()
#define mp make_pair 
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
*/
// order_of_key -> # less than k
// find_by_order -> k-th element
// pq max element                                          

void files() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

const double eps = 0.00000001;
const ll NMAX = 200010;
const ll inf = 1e16;
const ll modi = 1e9+7;

vector<int>al[NMAX];
vector<int>visited(1010);
int vred[NMAX];
ll temp = 0;
ll dfs(int node) {
    if ( visited[node] ) return 0;
    ll res = 0;
    visited[node] = 1;
    res += vred[node];
    for (auto u : al[node] ) {
        res += dfs(u);
    }
    temp += res;
    return res;
}
void solve() {
    int n;
    cin >> n;
    for (int i = 1 ; i < n ; i++ ) {
        int a,b;
        cin >> a >> b;
        al[a].pb(b);
        al[b].pb(a);
    }

    for (int i = 1;  i <= n ; i++ ) {
        cin >> vred[i];
    }

    if ( n <= 1000 ) {
        int q;cin>>q;while(q--){int a; cin >>a;}
        ll res = LLONG_MAX;
        int ii = 1;
        for (int i = 1 ; i <=n ; i++ ) {
            fill(all(visited),0);
            dfs(i);
            //cout << i << ' ' << temp << endl;
            if ( temp < res) {
                ii = i;
                res = temp;
            }
            temp = 0;
        }

        cout << ii << endl;
    }


}

int main () { 
    FAST
    int t=1;

    /*
    cin >> t;
    //*/

    int i = 1;
    while(t--) {
        //cout << "Case #" << i++ << ": " ;
        solve();
    }
}