Problem: Misha has a tree with characters written on the vertices. He can choose two vertices s and t of this tree and write down characters of vertices lying on a path from s to t. We'll say that such string corresponds to pair (s, t).

Misha has m queries of type: you are given 4 vertices a, b, c, d; you need to find the largest common prefix of the strings that correspond to pairs (a, b) and (c, d). Your task is to help him.

Input

The first line contains integer n (1 ≤ n ≤ 300 000) — the number of vertices in the tree.

Next follows a line consisting of n small English letters. The i-th character of the string corresponds to the character written on the i-th vertex. 

Next n - 1 lines contain information about edges. An edge is defined by a pair of integers u, v (1 ≤ u, v ≤ n, u ≠ v), separated by spaces.

The next line contains integer m (1 ≤ m ≤ 1 000 000) — the number of queries.

Next m lines contain information about queries. A query is defined by four integers a, b, c, d (1 ≤ a, b, c, d ≤ n), separated by spaces.

Output

For each query print the length of the largest common prefix on a separate line.

Examples

Input

6
bbbabb
2 1
3 2
4 3
5 2
6 5
6
2 5 3 1
1 5 2 3
5 6 5 6
6 3 4 1
6 2 3 4
2 2 4 5


Output

2
2
2
0
1
0

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
inline int read(void) {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') f = c == '-' ? -1 : 1, c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c & 15), c = getchar();
  return x * f;
}
inline int getm(long long x, int mod) { return (x % mod + mod) % mod; }
const int N = 300005;
const int mod1 = 998244353, mod2 = 1000000007;
const int inv1 = 729486258, inv2 = 576923081;
int n, m;
int pw[N][2], inv[N][2];
char s[N];
struct Edge {
  int to, nxt;
} E[N << 1];
int head[N], tot;
inline void add(int f, int t) {
  E[++tot] = (Edge){t, head[f]}, head[f] = tot;
  return;
}
int hh1[N][2], hh2[N][2];
int lg[N << 1], dep[N], fa[N][20], len[N], son[N], dfn[N], tt, st[N << 1][21];
int top[N], *up[N], *down[N];
void init(void) {
  pw[0][0] = pw[0][1] = inv[0][0] = inv[0][1] = 1;
  for (int i = 1; i <= n; ++i)
    pw[i][0] = 26ll * pw[i - 1][0] % mod1,
    pw[i][1] = 26ll * pw[i - 1][1] % mod2,
    inv[i][0] = 1ll * inv1 * inv[i - 1][0] % mod1,
    inv[i][1] = 1ll * inv2 * inv[i - 1][1] % mod2;
  for (int i = 1; i <= n << 1; ++i) lg[i] = lg[i >> 1] + 1;
  return;
}
void dfs1(int x, int from) {
  dep[x] = dep[from] + 1, fa[x][0] = from, st[dfn[x] = ++tt][0] = x;
  hh1[x][0] = (26ll * hh1[fa[x][0]][0] + (s[x] - 'a')) % mod1;
  hh1[x][1] =
      (hh1[fa[x][0]][1] + 1ll * pw[dep[x] - 1][0] * (s[x] - 'a')) % mod1;
  hh2[x][0] = (26ll * hh2[fa[x][0]][0] + (s[x] - 'a')) % mod2;
  hh2[x][1] =
      (hh2[fa[x][0]][1] + 1ll * pw[dep[x] - 1][1] * (s[x] - 'a')) % mod2;
  for (int i = 1; i < lg[dep[x]]; ++i) fa[x][i] = fa[fa[x][i - 1]][i - 1];
  for (int i = head[x]; i; i = E[i].nxt) {
    int y = E[i].to;
    if (y == from) continue;
    dfs1(y, x);
    st[++tt][0] = x, son[x] = len[son[x]] > len[y] ? son[x] : y;
  }
  len[x] = len[son[x]] + 1;
  return;
}
void dfs2(int x, int tp) {
  top[x] = tp;
  if (tp == x) {
    up[x] = new int[len[x] + 5], down[x] = new int[len[x] + 5];
    for (int y = x, l = 0; y != 0 && l <= len[x]; y = fa[y][0], ++l)
      up[x][l] = y;
  }
  down[tp][dep[x] - dep[tp]] = x;
  if (son[x]) dfs2(son[x], tp);
  for (int i = head[x]; i; i = E[i].nxt) {
    int y = E[i].to;
    if (y == fa[x][0] || y == son[x]) continue;
    dfs2(y, y);
  }
  return;
}
inline void init_st(void) {
  for (int k = 1; k < lg[tt]; ++k)
    for (int i = 1; i + (1 << k) - 1 <= tt; ++i)
      st[i][k] = dep[st[i][k - 1]] < dep[st[i + (1 << (k - 1))][k - 1]]
                     ? st[i][k - 1]
                     : st[i + (1 << (k - 1))][k - 1];
  return;
}
inline int lca(int l, int r) {
  l = dfn[l], r = dfn[r];
  if (l > r) std::swap(l, r);
  int k = lg[r - l + 1] - 1;
  return dep[st[l][k]] < dep[st[r - (1 << k) + 1][k]] ? st[l][k]
                                                      : st[r - (1 << k) + 1][k];
}
inline int kth(int x, int k) {
  if (k == 0)
    return x;
  else if (k >= dep[x])
    return 0;
  x = fa[x][lg[k] - 1], k ^= 1 << (lg[k] - 1);
  if (dep[top[x]] <= dep[x] - k)
    return down[top[x]][dep[x] - k - dep[top[x]]];
  else
    return up[top[x]][dep[top[x]] - dep[x] + k];
}
inline std::pair<int, int> hashh(int a, int b, int k) {
  int f = lca(a, b), l = dep[a] + dep[b] - dep[f] * 2 + 1;
  int hash1 = 0, hash2 = 0;
  if (k <= dep[a] - dep[f] + 1)
    hash1 = getm(hh1[a][0] - 1ll * pw[k][0] * hh1[kth(a, k)][0], mod1),
    hash2 = getm(hh2[a][0] - 1ll * pw[k][1] * hh2[kth(a, k)][0], mod2);
  else
    hash1 =
        (getm(hh1[a][0] - 1ll * pw[dep[a] - dep[f] + 1][0] * hh1[fa[f][0]][0],
              mod1) +
         1ll * inv[dep[f]][0] * pw[dep[a] - dep[f] + 1][0] % mod1 *
             getm(hh1[kth(b, l - k)][1] - hh1[f][1], mod1) % mod1) %
        mod1,
    hash2 =
        (getm(hh2[a][0] - 1ll * pw[dep[a] - dep[f] + 1][1] * hh2[fa[f][0]][0],
              mod2) +
         1ll * inv[dep[f]][1] * pw[dep[a] - dep[f] + 1][1] % mod2 *
             getm(hh2[kth(b, l - k)][1] - hh2[f][1], mod2) % mod2) %
        mod2;
  return std::make_pair(hash1, hash2);
}
inline int solve(int a, int b, int c, int d) {
  int f1 = lca(a, b), f2 = lca(c, d), l1 = dep[a] + dep[b] - dep[f1] * 2 + 1,
      l2 = dep[c] + dep[d] - dep[f2] * 2 + 1;
  int l = 1, r = std::min(l1, l2), res = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (hashh(a, b, mid) == hashh(c, d, mid))
      res = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  return res;
}
int main(void) {
  n = read();
  scanf("%s", s + 1);
  for (int i = 1, u, v; i < n; ++i)
    u = read(), v = read(), add(u, v), add(v, u);
  init();
  dfs1(1, 0), dfs2(1, 1);
  init_st();
  m = read();
  for (int i = 1, a, b, c, d; i <= m; ++i)
    a = read(), b = read(), c = read(), d = read(),
    printf("%d\n", solve(a, b, c, d));
  return 0;
}