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

namespace zad5k1
{
    internal class Program
    {
        static int max(int[]niz)
        {
            int m = 0,n=niz.Length,m1=0;
            for(int i=0;i<n;i++)
            {
                if (m < niz[i])
                {
                    m = niz[i];
                    m1 = i;
                }

            }
            return m1;
        }
        static void swap(ref List<int> l, ref List<int> d,int br,ref List<int>rez, ref List<int> rez1)
        {
            int m = l.Count,p;
            for(int i=0;i<m;i++)
            {
                if (d[i]==br)
                {
                    rez.Add(l[i]);
                    p = d[i];
                    d[i] = l[i];
                    l[i] = p;
                }
            }
            swapl(ref l, ref d, rez, ref rez,ref rez1);
        }
        static void swapl(ref List<int> l, ref List<int> d, List<int> br,ref List<int> rez, ref List<int> rez1)
        {
            rez1 = rez;
            rez.Clear();
            bool flag=false;
            if (rez.Count != 0)
                flag = true;
            int m = l.Count, p;
            for (int i = 0; i < m; i++)
            {
                if (br.Contains(d[i]))
                {
                    rez.Add(l[i]);
                    p = d[i];
                    d[i] = l[i];
                    l[i] = p;
                }
            }
            if (flag)
                swapl(ref l, ref d, rez, ref rez,ref rez1);
        }
        static void transfer(ref int[] niz,ref List<int>l,ref List<int> d,ref List<int> a)
        {
            List<int> pom=new List<int>();
            int m = max(niz);
            for(int i=0;i<d.Count;i++)
            {
                if (a.Contains(d[i]))
                {
                    pom.Add(l[i]);
                    niz[l[i]-1]+=niz[d[i] - 1];
                    niz[d[i] - 1] = 0;
                }
            }
            if (max(niz) == m && pom.Count!=0)
                transfer(ref niz, ref l, ref d, ref pom);
            else
            {
                if (pom.Count != 0)
                {
                    List<int> t = new List<int>();
                    List<int> t1 = new List<int>();
                    swap(ref l, ref d, max(niz), ref t, ref t1);
                    transfer(ref niz,ref l,ref d, ref t1);
                }
            }
        }
        static void Main(string[] args)
        {
            string[] nz;
            List<int> leva = new List<int>();
            List<int> desna = new List<int>();
            List<int> res = new List<int>();
            List<int> p1 = new List<int>();
            List<int> p2 = new List<int>();
            int n = int.Parse(Console.ReadLine());
            int[] niz = new int[n];
            int[] niz1 = new int[n];
            for (int i=0;i<n-1;i++)
            {
                nz = Console.ReadLine().Split();
                leva.Add(int.Parse(nz[0]));
                desna.Add(int.Parse(nz[1]));
            }
            nz = Console.ReadLine().Split();
            for(int i=0;i<n;i++)
            {
                niz[i] = int.Parse(nz[i]);
            }
            niz1 = niz;
            swap(ref leva, ref desna, max(niz), ref p1, ref p2);
            transfer(ref niz, ref leva, ref desna, ref p2);
            res.Add(max(niz));
            niz = niz1;
            int q=int.Parse(Console.ReadLine());
            for(int i=0;i<q;i++)
            {
                nz = Console.ReadLine().Split();
                int a = int.Parse(nz[1]);
                niz[a-1]+=int.Parse(nz[0]);
                niz1 = niz;
                swap(ref leva, ref desna, max(niz), ref p1, ref p2);
                transfer(ref niz, ref leva, ref desna, ref p2);
                res.Add(max(niz));
                niz = niz1;
            }
            foreach(int i in res)
            {
                Console.WriteLine(i+1);
            }
            Console.ReadLine();
        }
    }
}