using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Carobnjaci
{
    internal class Program
    {   
        struct portali
        {
            public int x;
            public int y;
        }
        struct zalozi
        {
            public int z;
            public int b;
        }
        static void komsije(int n, portali[] a, ref int[] k,ref int[] z)
        {
            for (int i = 0; i < a.Length; i++)
            {
                if (a[i].x == n && z[i] == 0)
                {
                    prosiri(ref k, a[i].y);
                    z[i] = 1;
                }
                else if(a[i].y == n && z[i] == 0)
                {
                    prosiri(ref k, a[i].x);
                    z[i] = 1;
                }
            }
        }
        static void prosiri(ref int[] a, int n)
        {
            int[] b = new int[a.Length + 1];
            for (int i = 0; i < a.Length; i++)
            {
                b[i + 1] = a[i];
            }
            b[0] = n;
            a = new int[b.Length];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = b[i];
            }
        }
        static void skupi(ref int[] a)
        {
            int[] b = new int[a.Length - 1];
            for (int i = 1; i < a.Length; i++)
            {
                b[i - 1] = a[i];
            }
            a = new int[b.Length];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = b[i];
            }
        }
        static void unos(ref portali[] a,int n)
        {
            for(int i=0;i<n-1;i++)
            {
                string[] red=Console.ReadLine().Split(' ');
                a[i].x = int.Parse(red[0]);
                a[i].y=int.Parse(red[1]);
            }
        }
        static void unosz(ref int[] a, int n)
        {
            string[] red = Console.ReadLine().Split(' ');
            for (int i = 1; i < n+1; i++)
            {
                a[i]= int.Parse(red[i-1]);
            }
        }
        static void unosZa(ref zalozi[] z,int n)
        {
            for (int i = 0; i< n;i++)
            {
                string[] red = Console.ReadLine().Split(' ');
                z[i].z = int.Parse(red[0]);
                z[i].b = int.Parse(red[1]);
            }
        }
        static void prebroji(portali[] p,int n, int[] zab, int[]z,ref int s,int l)
        {
            int[]k =new int[0];
            
            komsije(n, p, ref k,ref zab);
            if(k.Length!=0)
            {
                foreach(int x in k)
                {
                    s += z[x]*l;
                    //Console.WriteLine(s);
                    
                    skupi(ref k);
                    prebroji(p, x,zab,z,ref s,l+1);

                }
            }
        }
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            portali[] p=new portali[n];
            unos(ref p, n);
            int[] z= new int[n+1];
            unosz(ref z, n);
            int q = int.Parse(Console.ReadLine());
            zalozi[] m=new zalozi[q];
            unosZa(ref m, q);
            //int[] hh = new int[5];
            //portali o;
            //o.x = 3;
            //o.y = 4;
            //komsije(2, p, ref hh, hh);
            //Console.WriteLine(hh[0]);
            //Console.WriteLine(z[5] +"mdma");
            int[] zab = new int[p.Length];
            int s = 0;
            int min = int.MaxValue;
            int indeks = 0;
            for (int i = 1; i <= n; i++)
            {
                prebroji(p, i, zab, z, ref s, 1);
                zab = new int[p.Length];
                if(s<min)
                {
                    min = s;
                    indeks = i;
                }
                s = 0;
            }
            //Console.WriteLine(min);
            Console.WriteLine(indeks);
            for(int j=0;j<q;j++)
            {   
                min=int.MaxValue;
                z[m[j].b] += m[j].z;
                for (int i = 1; i <= n; i++)
                {
                    s = 0;
                    prebroji(p, i, zab, z, ref s, 1);
                    zab = new int[p.Length];
                    if(s<min)
                    {
                        min = s;
                        indeks = i;
                    }
                    s = 0;
                }
                //Console.WriteLine(min);
                Console.WriteLine(indeks);
            }

        }
    }
}