#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
void gi(int &x) {
  static char r[(1 << 24) + 16], *s = r, *l = r + (1 << 24);
  x = 0;
  if (!*s) memset(r, 0, (1 << 24)), cin.read(r, (1 << 24)), s = r;
  while (*s && (*s < 48 || *s > 57)) ++s;
  while (*s >= 48 && *s <= 57) {
    x = x * 10 + *s - 48, ++s;
    if (s == l) memset(r, 0, (1 << 24)), cin.read(r, (1 << 24)), s = r;
  }
  ++s;
}
char QQ[(1 << 24) + 16], *OP = QQ, *LP = QQ + (1 << 24);
void pn(int x) {
  char *B = OP, c, *E;
  int t;
  if (!x) t = x / 10, c = x - 10 * t + 48, *OP++ = c, x = t;
  while (x) t = x / 10, c = x - 10 * t + 48, *OP++ = c, x = t;
  E = OP - 1;
  while (B < E) swap(*B, *E), ++B, --E;
  if (OP > LP) cout.write(QQ, OP - QQ), OP = QQ;
}
void pc(char c) { *OP++ = c; }
void ga(int N, int *A) {
  for (int i(0); i < N; i++) gi(A[i]);
}
struct UF {
  int v;
  UF(long long a = int(1e9 + 1)) { v = a; }
  UF mg(UF r) { return UF(min(v, r.v)); }
};
struct sX {
  UF P[((100005) * 60)];
  int N, t, T[(100005) * 4], L[((100005) * 60)], R[((100005) * 60)], l;
  void ini(int n) {
    N = 1 << (int(log2(n) - (1e-10)) + 1), *T = t = 1, l = (N << 1) + 2;
    for (int i(0); i < N << 1; i++)
      P[i] = UF(), L[i] = i << 1, R[i] = i << 1 | 1;
  }
  int st(int b, UF v) { return T[t] = st(b, v, T[t - 1], 0, N - 1), t++; }
  int st(int b, UF v, int u, int B, int E) {
    if (B > b || E < b) return u;
    int I = u;
    u = l++, L[u] = L[I], R[u] = R[I], P[u] = P[I];
    if (B == E) return P[u] = v, u;
    L[u] = st(b, v, L[u], B, (B + E) >> 1),
    R[u] = st(b, v, R[u], (B + E) / 2 + 1, E);
    P[u] = P[L[u]].mg(P[R[u]]);
    return u;
  }
  UF gt(int b, int e, int t) { return gt(b, e, T[t], 0, N - 1); }
  UF gt(int b, int e, int u, int B, int E) {
    if (b <= B && e >= E) return P[u];
    if (b > (B + E) >> 1) return gt(b, e, R[u], (B + E) / 2 + 1, E);
    if (e <= (B + E) >> 1) return gt(b, e, L[u], B, (B + E) >> 1);
    return gt(b, e, L[u], B, (B + E) >> 1)
        .mg(gt(b, e, R[u], (B + E) / 2 + 1, E));
  }
} G;
vector<int> g[(100005)];
int N, Q, A[(100005)], D[(100005)], B[(100005)], E[(100005)], R, l, a, b,
    H[(100005)], T[(100005) * 2], L;
void dfs(int u, int p, int d) {
  D[u] = d++, B[u] = l++;
  for (auto &h : g[u])
    if (h ^ p) dfs(h, u, d);
  E[u] = l - 1;
}
bool cp(int a, int b) { return D[a] < D[b]; }
int main(void) {
  ios_base::sync_with_stdio(0);
  gi(N), gi(R), --R, ga(N, A), iota(H, H + N, 0), G.ini(N),
      fill(T, T + (100005) * 2, N);
  for (int i(0); i < N - 1; i++)
    gi(a), gi(b), g[--a].push_back(--b), g[b].push_back(a);
  dfs(R, R, 0), sort(H, H + N, cp);
  for (int i(0); i < N; i++) T[D[H[i]]] = G.st(B[H[i]], {A[H[i]]});
  int _ = 0;
  gi(_);
  for (int i(0); i < _; i++)
    gi(a), gi(b), a = (a + L) % N, b = (b + L) % N,
                  pn(L = G.gt(B[a], E[a], T[b + D[a]]).v), pc(10);
  cout.write(QQ, OP - QQ);
  return 0;
}
