#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define PI acos(-1)
#define LSB(i) ((i) & -(i))
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define sc second
#define th third
#define fo fourth
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
#define MOD 1000000007
#define endl "\n"

#define all(data)       data.begin(),data.end()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()
#define ima_li_te(D,d)  find(all(D),d)
#define MAXN 200007
vector<ll> adj[MAXN];
ll a[MAXN],sum[MAXN],vis[MAXN],h[MAXN],p[MAXN],z[MAXN],b[MAXN],rez[MAXN],sigma=0;
void DFS(ll i,ll hh)
{
    vis[i]=true;
    h[i]=hh; sum[i]=a[i];
    for(auto j:adj[i])
    {
        if(!vis[j])
        {
            DFS(j,hh+1);
            p[j]=i;
            sum[i]+=sum[j];
        }
    }
}
void DFS1(ll i)
{
    vis[i]=true;
    for(auto j:adj[i])
    {
        if(!vis[j])
        {
            rez[j]=rez[i]+sigma-2*sum[j];
            DFS1(j);
        }
    }
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    ll n,x,y; cin>>n;
    for(int i=1;i<n;i++)
    {
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) sigma+=a[i];
    ll q; cin>>q;
    for(int i=1;i<=q;i++) cin>>z[i]>>b[i];
    DFS(1,0);
    for(int i=1;i<=n;i++) rez[1]+=h[i]*a[i];
    for(int i=1;i<=n;i++) vis[i]=false;
    DFS1(1);
    //cout<<sigma<<endl;
    //for(int i=1;i<=n;i++) cout<<sum[i]<<" ";
    //cout<<endl;
    //for(int i=1;i<=n;i++) cout<<rez[i]<<" ";
    ll sol=LLONG_MAX,itr;
    for(int i=1;i<=n;i++)
    {
        if(rez[i]<sol)
        {
            sol=rez[i];
            itr=i;
        }
    }
    cout<<itr<<endl;
    return 0;
}