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;
char B[1 << 26], *S = B;
inline int read() {
  int x;
  char c;
  while ((c = *S++) < '0' || c > '9')
    ;
  for (x = c - '0'; (c = *S++) >= '0' && c <= '9';) x = x * 10 + c - '0';
  return x;
}
char s[300000 + 5], ss[300000 * 10 + 5];
struct edge {
  int nx, t;
} e[300000 * 2 + 5];
int h[300000 + 5], en, fa[19][300000 + 5], d[300000 + 5], t[300000 + 5],
    mx[300000 + 5], f[300000 + 5], o[300000 + 5];
int p[300000 + 5], r[300000 + 5], a[300000 + 5], b[300000 + 5], sn;
vector<int> v1[300000 + 5], v2[300000 + 5];
inline void ins(int x, int y) {
  e[++en] = (edge){h[x], y};
  h[x] = en;
  e[++en] = (edge){h[y], x};
  h[y] = en;
}
void dfs(int x) {
  a[x] = (a[fa[0][x]] + 1LL * s[x] * p[d[x]]) % 998244353;
  b[x] = (233LL * b[fa[0][x]] + s[x]) % 998244353;
  for (int i = h[x]; i; i = e[i].nx)
    if (e[i].t != fa[0][x]) {
      fa[0][e[i].t] = x;
      d[e[i].t] = d[x] + 1;
      dfs(e[i].t);
      if (t[e[i].t] + 1 > t[x]) t[x] = t[e[i].t] + 1, mx[x] = e[i].t;
    }
}
void build(int x) {
  if (!f[x]) {
    f[x] = x;
    for (int i = 0, j = x; i < t[x]; ++i, j = fa[0][j]) v2[x].push_back(j);
  }
  v1[f[x]].push_back(x);
  if (mx[x]) f[mx[x]] = f[x];
  for (int i = h[x]; i; i = e[i].nx)
    if (e[i].t != fa[0][x]) build(e[i].t);
}
inline int up(int x, int k) {
  if (k <= d[x] - d[f[x]]) return v1[f[x]][d[x] - d[f[x]] - k];
  x = fa[o[k]][x];
  k -= 1 << o[k];
  if (k <= d[x] - d[f[x]]) return v1[f[x]][d[x] - d[f[x]] - k];
  return v2[f[x]][k - d[x] + d[f[x]]];
}
inline int lca(int x, int y) {
  if (d[x] < d[y]) swap(x, y);
  x = up(x, d[x] - d[y]);
  if (x == y) return x;
  for (int i = 19; i--;)
    if (fa[i][x] != fa[i][y]) x = fa[i][x], y = fa[i][y];
  return fa[0][x];
}
inline int inv(int x) {
  int r = 1, y = 998244353 - 2;
  for (; y; y >>= 1, x = 1LL * x * x % 998244353)
    if (y & 1) r = 1LL * r * x % 998244353;
  return r;
}
inline int cala(int x, int y) {
  return 1LL * (a[x] + 998244353 - a[fa[0][y]]) * r[d[y]] % 998244353;
}
inline int calb(int x, int y) {
  return (b[x] + 998244353 - 1LL * b[y] * p[d[x] - d[y]] % 998244353) %
         998244353;
}
int cal(int x, int y, int l, int z) {
  if (z <= d[x] - d[l]) return cala(x, up(x, z));
  y = up(y, d[x] + d[y] - 2 * d[l] - z);
  return (1LL * cala(x, l) * p[d[y] - d[l]] + calb(y, l)) % 998244353;
}
inline void out(int x) {
  int z[10], zn = 0;
  if (!x) z[zn++] = 0;
  while (x) z[zn++] = x % 10, x /= 10;
  while (zn--) ss[sn++] = z[zn] + '0';
  ss[sn++] = '\n';
}
int main() {
  B[fread(B, 1, 1 << 26, stdin)] = 0;
  int n = read(), i, j, x1, x2, y1, y2, l1, l2, ll, rr, mid, ans;
  for (i = 2; i <= n; ++i) o[i] = o[i >> 1] + 1;
  for (i = 1; i <= n; ++i)
    while ((s[i] = *S++) < 'a' || s[i] > 'z')
      ;
  for (i = 1; i < n; ++i) ins(read(), read());
  for (p[0] = i = 1; i <= n; ++i) p[i] = 233LL * p[i - 1] % 998244353;
  for (r[i = n] = inv(p[n]); i--;) r[i] = 233LL * r[i + 1] % 998244353;
  dfs(1);
  build(1);
  for (i = 1; i < 19; ++i)
    for (j = 1; j <= n; ++j) fa[i][j] = fa[i - 1][fa[i - 1][j]];
  for (i = read(); i--;) {
    x1 = read();
    y1 = read();
    l1 = lca(x1, y1);
    x2 = read();
    y2 = read();
    l2 = lca(x2, y2);
    for (ans = ll = 0,
        rr = min(d[x1] + d[y1] - 2 * d[l1], d[x2] + d[y2] - 2 * d[l2]);
         ll <= rr;) {
      int mid = ll + rr >> 1;
      if (cal(x1, y1, l1, mid) == cal(x2, y2, l2, mid))
        ans = ll = mid + 1;
      else
        rr = mid - 1;
    }
    out(ans);
  }
  fwrite(ss, 1, sn, stdout);
}