#include <bits/stdc++.h>
using namespace std;

struct banka{
    int kraj;
    int zlatnik;
};

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

    int n;
    cin >> n;
    vector<vector<banka>> tree(n);
    vector<int> z1(n);

    for(int i = 0;i < n-1;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        tree[a].push_back({b,1});
    }

    for(int i = 0;i < n;i++) cin >> z1[i];

    vector<unsigned long long> zbirovi(n,0);

    int mn = ULLONG_MAX, k = 0;
    for(int i = 0;i < n;i++){
        int z = 1;
        for(int j = 0;j < i;j++){
            zbirovi[i] += z1[j]*z;
            z++;
        }
        z = 1;
        for(int j = i+1;j < n;j++){
            zbirovi[i] += z1[j]*z;
            z++;
        }
        if(zbirovi[i] < mn){
            mn = zbirovi[i];
            k = i;
        }
    }

    int q;
    cin >> q;

    cout << k+1 << "\n";
    long long int fs,fd;
    for(int i = 0;i < q;i++){
        cin >> fs >> fd;

        mn = ULLONG_MAX; k = 0;
        int z = 1;
        for(int j = fd-2;j >= 0;j--){
            zbirovi[j] += fs*z;
            z++;
        }
        z = 1;
        for(int j = fd;j < n;j++){
            zbirovi[j] += fs*z;
            z++;
        }

        for(int j = 0;j < n;j++){
            if(zbirovi[j] < mn){
                mn = zbirovi[j];
                k = j;
            }
        }

        cout << k+1 << "\n";
    }
}