#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 2e5 + 2;
const int inf = 2e9;
vector<int> g[N];
ll a[N], uk;
int par[N][18], in[N], out[N], tsz;
void Dfs(int s, int e) {
    in[s] = tsz++;
    par[s][0] = e;
    for (int i = 1; i < 18; i++) par[s][i] = par[par[s][i - 1]][i - 1];
    for (int u : g[s]) if (u != e) {
        Dfs(u, s);
        a[s] += a[u];
    }
    out[s] = tsz++;
}
bool Ancestor(int u, int v) {
    return in[u] <= in[v] && out[v] <= out[u];
}
int Lca(int u, int v) {
    if (Ancestor(u, v)) return u;
    if (Ancestor(v, u)) return v;
    for (int i = 17; i >= 0; i--) {
        if (par[u][i] && !Ancestor(par[u][i], v)) u = par[u][i];
    }
    return par[u][0];
}
int Dfsq0(int s, int e) {
    for (int u : g[s]) {
        if (u == e) continue;
        if (a[u] >= (uk + 1) / 2) return Dfsq0(u, s);
    }
    return s;
}
void RollBack(int s, int e) {
    for (int u : g[s]) {
        if (u == e) continue;
        a[s] -= a[u];
        RollBack(u, s);
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        uk += a[i];
    }
    Dfs(1, 0);
    int q; cin >> q;
    if (q == 0) {
        int x = Dfsq0(1, 0);
        if (uk % 2 == 0 && a[x] == uk / 2 && par[x][0]) smin(x, par[x][0]);
        cout << x << en;
        return 0;
    }
    RollBack(1, 0);
    /*
        - lanac lazy segment tree (update prefix) onda isto kao za q = 0
        - binary tree svakog roditelji pa iz ruta se moze traziti resenje
    */
    return 0;
}