#include <iostream>
#include <vector>
#include <string>
#include<algorithm>
#include<queue>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    queue<int> s;
    bool a[20000];
    int n, m, i, j, k, o, p;
    cin >> n;
    vector<vector<int>> v(n);
    for (i = 0; i < n; i++)
        a[i] = false;
    for (i = 0; i < n-1; i++)
    {
        cin >> o >> p;
        v[o-1].push_back(p-1);
        v[p-1].push_back(o-1);
    }
    int b[20000];
    for (i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    int br[20000];
    for (i = 0; i < n; i++)
        br[i] = 0;
    int y = 1;
    int t=0;
    int ccc = 0;
    int poz=0;
    for (j = 0; j < n; j++)
    {
        t = 0;
        s.push(j);
        y = 1;
        while (!s.empty())
        {
            k = s.front();
            s.pop();
            if (a[k] == false)
            {
                
                a[k] = true;
                //cout << k;
                for (i = 0; i < v[k].size(); i++)
                {
                    s.push(v[k][i]);
                    if (br[v[k][i]]==0)
                    br[v[k][i]] = y;
                    
                }
                if(k!=j)
                t += b[k] * br[k];
                y++;
            }
            

        }
        if (t < ccc || ccc == 0)
        {
            ccc = t;
            poz = j;
        }
        for (i = 0; i < n; i++)
        {
            a[i] = false;
            br[i] = 0;
        }
    }
    cout << poz + 1<<endl;
    int q;
    cin >> q;
    int ji;
    int ou, oh;
    for (ji = 0; ji < q; ji++)
    {
        ccc = 0;
        cin >> ou >> oh;
        b[oh - 1] += ou;
        for (j = 0; j < n; j++)
        {
            t = 0;
            s.push(j);
            y = 1;
            while (!s.empty())
            {
                k = s.front();
                s.pop();
                if (a[k] == false)
                {

                    a[k] = true;
                    //cout << k;
                    for (i = 0; i < v[k].size(); i++)
                    {
                        s.push(v[k][i]);
                        br[v[k][i]] = y;

                    }
                    if (k != j)
                        t += b[k] * br[k];
                    y++;
                }
               

            }
            if (t < ccc || ccc == 0)
            {
                ccc = t;
                poz = j;
            }
            for (i = 0; i < n; i++)
            {
                a[i] = false;
                br[i] = 0;
            }
        }
        cout << poz + 1<<endl;
    }
    
    
    
    
}