#include <stdio.h>
main()
{
    int n, q;
    int r = 0;
    int maks = 0;
    int maks1 = -1;
    int zbir = 0;
    int reca = 0;
    scanf("%d", &n);
    int ds[n];
    int x[n - 1];
    int y[n - 1];
    int a[n];
    for(int i = 0; i < n - 1; i++)
        ds[i] = 0;
    for(int i = 0; i < n - 1; i++)
    {
        scanf("%d %d", &x[i], &y[i]);
        ds[x[i] - 1]++;
        ds[y[i] - 1]++;
        if((ds[x[i] - 1] > maks1) || (ds[x[i] - 1] == maks1 && x[i] < reca))
          {
               reca = x[i];
               maks1 = ds[x[i] - 1];

          }
        if((ds[y[i] - 1] > maks1) || (ds[y[i] - 1] == maks1 && y[i] < reca))
          {
            reca = y[i];
            maks1 = ds[y[i] - 1];

          }
    }
    for(int i = 0; i < n; i++)
       {
           scanf("%d", &a[i]);

       }
    for(int i = 0; i < n; i++)
       {
           if(a[i] > maks)
           {
                maks = a[i];
                r = i + 1;
           }
           zbir += a[i];
       }
    scanf("%d", &q);
    int z[q];
    int b[q];
    for(int i = 0; i < q; i++)
    {
        scanf("%d %d", &z[i], &b[i]);
    }

    if(2 * maks > zbir)
        printf("%d", r);
    else
    {
        printf("%d", reca);
    }

}