#include <stdio.h>
#define INFINITY 9999
struct veza{
    long int x;
    int y;
}veza;
void printg(long int n,long int g[][n]){
    for(long int i=0;i<n;i++){
        for(long int j=0;j<n;j++)
            printf("%d ",g[i][j]);
        printf("\n");}
}
void floydWarshall(long int n,long int g[][n])
{
    long int i,j,k;
    for (k = 0; k < n; k++) {
        for (i = 0; i < n; i++) {
            for (j = 0; j < n; j++) {
                if (g[i][k] + g[k][j] < g[i][j])
                    g[i][j] = g[i][k] + g[k][j];
            }
        }
    }
}
int check(long int n,long int g[][n]){
    long int zbir[n];
    for(long int i=0;i<n;i++)
        zbir[i]=0;
    for(long int i=0;i<n;i++)
        for(long int j=0;j<n;j++){
            if(g[i][j]!=INFINITY && i!=j)
                zbir[i]+=g[i][j];
            if(g[j][i]!=INFINITY && i!=j)
                zbir[i]+=g[j][i];}
    long int min=zbir[0];
    long int imin=0;
    for(long int i=0;i<n;i++)
        if(min>zbir[i]){
            imin=i+1;
            min=zbir[i];}
    return imin;
}
int main() {
    long int n,q;
    scanf("%d",&n);
    long int b[n];
    struct veza v[n-1];
    for(long int i=0;i<n-1;i++){
        scanf("%d%d",&v[i].x,&v[i].y);
        v[i].x--;v[i].y--;}
    for(long int i=0;i<n;i++){
        scanf("%d",&b[i]);
    }
    long int g[n][n];
    for(long int i=0;i<n;i++)
        for(long int j=0;j<n;j++)
            if(i==j)
                g[i][j]=0;
            else
                g[i][j]=INFINITY;
    for(long int i=0;i<n-1;i++)
        g[v[i].x][v[i].y]=b[i+1];
    scanf("%d",&q);
    if(q==0){
        floydWarshall(n,*g);
        printf("%d",check(n,g));}
}