#include <bits/stdc++.h>

using namespace std;
int dist[20000][20000];
void bfs(int c, vector<int> v[],int n){
    dist[c][c] = 0;
    bool posecen[n] = {false};
    queue<int> q;
    q.push(c);
    while(!q.empty()){
        int x = q.front();
        for(int i = 0; i<v[x].size(); i++){
            if(!posecen[v[x].at(i)]){
                q.push(v[x].at(i));
                dist[c][v[x].at(i)] = dist[c][x]+1;
            }
        }
        posecen[x] = true;
        q.pop();
    }
}
int main()
{
    int n;
    cin>>n;
    vector<int> g[n+1];
    int zlato[n+1];
    for(int i = 1; i<n; i++){
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i = 1; i<=n; i++){
        cin>>zlato[i];
    }
    for(int i = 1; i<=n; i++){
        bfs(i,g,n+1);
    }
    int minimale[n+1] = {0};
    int ind = -1;
    long long s = 9000000000000;
    for(int i = 1; i<=n; i++){
        for(int j = 1; j<=n; j++){
            minimale[i]+=dist[i][j]*zlato[j];
        }
        if(minimale[i]<s){
            s = minimale[i];
            ind = i;
        }
    }
    int sol[n+1];
    sol[0] = ind;
    int q;
    cin>>q;
    for(int i = 1; i<=q; i++){
        s = 9000000000000;
        ind = -1;
        int k, c;
        cin>>k>>c;
        for(int j = 1; j<=n; j++){
            minimale[j]+=k*dist[j][c];
            if(s>minimale[j]){
                s = minimale[j];
                ind = j;
            }
        }
        sol[i] = ind;
    }
    for(int i = 0; i<=q; i++){
        cout<<sol[i]<<endl;
    }
    return 0;
}