#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define sz(x) (int)x.size()
#define f first
#define s second
#define mod 1000000007
// const int mod = 998244353;
// OVERFLOW!!!!!!!!!!!!!!!!!!
const int maxn = 2e5 + 100;
vector<int> g[maxn];
vector<int> a(maxn);
int main()
{
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    ll ans = 1e18, res;
    for (int i = 1; i <= n; i++)
    {
        vector<int> d(n + 1, 1e9);
        queue<int> q;
        q.push(i);
        d[i] = 0;
        while (!q.empty())
        {
            auto u = q.front();
            q.pop();
            for (auto it : g[u])
            {
                if (d[it] > d[u] + a[it] + 1)
                {
                    d[it] = d[u] + a[it] + 1;
                    q.push(it);
                }
            }
        }
        ll zbir = 0;
        for (int i = 1; i <= n; i++)
            zbir += d[i];
        if (zbir < ans)
        {
            ans = min(ans, zbir);
            res = i;
        }
    }
    cout << res << "\n";
    int q;
    cin >> q;
    while (q--)
    {
        int a, b;
        cin >> a >> b;
        cout << "0\n";
    }
    return 0;
}