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>
using namespace std;
const long long mod1 = 1004535809, mod2 = 167772161;
long long n, len, m, q, dfn[1000000], ind[1000000], a[1000000], size[1000000],
    top[1000000], son[1000000], fa[1000000], dep[1000000], nex[1000000],
    wen[1000000], hea[1000000], lo1[1000000], lo2[1000000], inv1[1000000],
    inv2[1000000], ha11[1000000], ha12[1000000], ha21[1000000], ha22[1000000];
char s[1000000];
long long mo1(long long x) {
  return (x >= mod1) ? ((x >= mod1) ? x - mod1 : x) : x;
}
long long mo2(long long x) {
  return (x >= mod2) ? ((x >= mod2) ? x - mod2 : x) : x;
}
long long kp(long long a, long long b, long long p) {
  long long c = 1;
  while (b) {
    if (b & 1) c = c * a % p;
    a = a * a % p;
    b >>= 1;
  }
  return c;
}
void add(long long x, long long y) {
  ++len;
  nex[len] = hea[x];
  wen[len] = y;
  hea[x] = len;
}
void dfs(long long x, long long y) {
  fa[x] = y;
  size[x] = 1;
  dep[x] = dep[y] + 1;
  ha21[x] = mo1(26ll * ha21[y] % mod1 + a[x]);
  ha22[x] = mo2(26ll * ha22[y] % mod2 + a[x]);
  ha11[x] = mo1(ha11[y] + 1ll * lo1[dep[x] - 1] * a[x] % mod1);
  ha12[x] = mo2(ha12[y] + 1ll * lo2[dep[x] - 1] * a[x] % mod2);
  for (long long i = hea[x]; i; i = nex[i])
    if (wen[i] != y) {
      dfs(wen[i], x);
      if (size[wen[i]] > size[son[x]]) son[x] = wen[i];
      size[x] += size[wen[i]];
    }
}
void dfs1(long long x) {
  top[x] = (son[fa[x]] == x) ? top[fa[x]] : x;
  dfn[x] = ++m;
  ind[m] = x;
  if (son[x]) dfs1(son[x]);
  for (long long i = hea[x]; i; i = nex[i])
    if (wen[i] != fa[x] && wen[i] != son[x]) dfs1(wen[i]);
}
long long lca(long long x, long long y) {
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    x = fa[top[x]];
  }
  return (dep[x] > dep[y]) ? y : x;
}
long long dis(long long x, long long y, long long z) {
  return (dep[x] + dep[y] - (dep[z] << 1) + 1);
}
long long kth(long long x, long long y) {
  while (dep[x] - dep[top[x]] < y)
    y -= dep[x] - dep[top[x]] + 1, x = fa[top[x]];
  return ind[dfn[x] - y];
}
long long get1(long long x, long long y, long long z, long long l) {
  if (dep[x] - dep[z] + 1 >= l) {
    y = kth(x, l);
    return (ha21[x] - 1ll * ha21[y] * lo1[dep[x] - dep[y]] % mod1 + mod1) %
           mod1;
  }
  long long ans = (ha21[x] -
                   1ll * ha21[fa[z]] * lo1[dep[x] - dep[z] + 1] % mod1 + mod1) %
                  mod1,
            t = lo1[dep[x] - dep[z] + 1];
  x = kth(y, dis(x, y, z) - l);
  ans += 1ll * (ha11[x] - ha11[z] + mod1) * inv1[dep[z]] % mod1 * t % mod1;
  return mo1(ans);
}
long long get2(long long x, long long y, long long z, long long l) {
  if (dep[x] - dep[z] + 1 >= l) {
    y = kth(x, l);
    return (ha22[x] - 1ll * ha22[y] * lo2[dep[x] - dep[y]] % mod2 + mod2) %
           mod2;
  }
  long long ans = (ha22[x] -
                   1ll * ha22[fa[z]] * lo2[dep[x] - dep[z] + 1] % mod2 + mod2) %
                  mod2,
            t = lo2[dep[x] - dep[z] + 1];
  x = kth(y, dis(x, y, z) - l);
  ans += 1ll * (ha12[x] - ha12[z] + mod2) * inv2[dep[z]] % mod2 * t % mod2;
  return mo2(ans);
}
long long check(long long x1, long long y1, long long z1, long long x2,
                long long y2, long long z2, long long l) {
  return (get1(x1, y1, z1, l) == get1(x2, y2, z2, l) &&
          get2(x1, y1, z1, l) == get2(x2, y2, z2, l));
}
long long solve(long long x1, long long y1, long long x2, long long y2) {
  long long z1 = lca(x1, y1), z2 = lca(x2, y2);
  long long l = 0, r = min(dis(x1, y1, z1), dis(x2, y2, z2)) + 1,
            mid = (l + r) >> 1;
  do {
    if (check(x1, y1, z1, x2, y2, z2, mid))
      l = mid;
    else
      r = mid;
    mid = (l + r) >> 1;
  } while (l + 1 < r);
  return l;
}
signed main() {
  scanf("%lld", &n);
  scanf("%s", s);
  for (long long i = 1; i <= n; i++) a[i] = s[i - 1] - 97;
  lo1[0] = lo2[0] = inv1[0] = inv2[0] = 1;
  long long iv1 = kp(26, mod1 - 2, mod1), iv2 = kp(26, mod2 - 2, mod2);
  for (long long i = 1; i <= n; i++)
    lo1[i] = 1ll * lo1[i - 1] * 26 % mod1,
    lo2[i] = 1ll * lo2[i - 1] * 26 % mod2;
  for (long long i = 1; i <= n; i++)
    inv1[i] = 1ll * inv1[i - 1] * iv1 % mod1,
    inv2[i] = 1ll * inv2[i - 1] * iv2 % mod2;
  for (long long i = 1; i < n; i++) {
    long long x, y;
    scanf("%lld%lld", &x, &y);
    add(x, y);
    add(y, x);
  }
  dfs(1, 0);
  dfs1(1);
  scanf("%lld", &q);
  for (long long i = 1; i <= q; i++) {
    long long x, y, xx, yy;
    scanf("%lld%lld%lld%lld", &x, &y, &xx, &yy);
    printf("%lld\n", solve(x, y, xx, yy));
  }
  return 0;
}