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>
const long long N = 600005, bse = 19260817, mod = 998244353, inv = 494863259,
                M = 21;
using namespace std;
long long up[N], dn[N], pw[N], iv[N], dep[N], n, m, x, y, fa[N], a, b, lg[N],
    sn[N], sg[N], sz[N], tp[N], bc[N], cnt;
char s[N];
struct edge {
  long long to, nx;
} e[N];
long long hd[N], S;
void add(long long fr, long long to) {
  e[++S] = (edge){to, hd[fr]}, hd[fr] = S;
}
void dfs(long long k, long long f) {
  fa[k] = f, dep[k] = dep[f] + 1, sz[k] = 1;
  dn[k] = (dn[f] * bse + s[k] - 'a') % mod,
  up[k] = ((s[k] - 'a') * pw[dep[f]] + up[f]) % mod;
  for (long long i = hd[k]; i; i = e[i].nx)
    if (e[i].to != f)
      dfs(e[i].to, k), sz[k] += sz[e[i].to],
          sn[k] = sz[e[i].to] > sz[sn[k]] ? e[i].to : sn[k];
}
void dfs(long long k, long long f, long long top) {
  tp[k] = top, sg[k] = ++cnt, bc[cnt] = k;
  if (sn[k]) dfs(sn[k], k, top);
  for (long long i = hd[k]; i; i = e[i].nx)
    if (e[i].to != f && e[i].to != sn[k]) dfs(e[i].to, k, e[i].to);
}
long long lca(long long x, long long y) {
  while (tp[x] != tp[y]) {
    if (dep[tp[x]] < dep[tp[y]]) swap(x, y);
    x = fa[tp[x]];
  }
  return dep[x] < dep[y] ? x : y;
}
long long gln(long long a, long long b, long long &lc) {
  lc = lca(a, b);
  return dep[a] + dep[b] - dep[lc] * 2 + 1;
}
long long gfa(long long x, long long p) {
  while (x) {
    if (dep[x] - dep[tp[x]] >= p) return bc[sg[x] - p];
    p -= dep[x] - dep[tp[x]] + 1, x = fa[tp[x]];
  }
  return 0;
}
long long ghs(long long s, long long t, long long lc, long long ln) {
  if (dep[s] - dep[lc] + 1 >= ln) {
    long long f = gfa(s, ln);
    return ((up[s] - up[f]) * iv[dep[f]] % mod + mod) % mod;
  } else {
    long long l = dep[s] - dep[lc],
              y = gfa(t, dep[s] + dep[t] - 2 * dep[lc] - ln + 1);
    long long u = ((up[s] - up[lc]) * iv[dep[lc]] % mod + mod) % mod,
              d = (dn[y] - dn[fa[lc]] * pw[ln - l] % mod + mod) % mod;
    return (u * pw[ln - l] + d) % mod;
  }
}
void solve(long long a, long long b, long long c, long long d) {
  long long la, lc, lna, lnc, l = 0, r, ans, mid;
  lna = gln(a, b, la), lnc = gln(c, d, lc);
  r = min(lna, lnc);
  while (l <= r) {
    mid = l + r >> 1;
    if (ghs(a, b, la, mid) == ghs(c, d, lc, mid))
      ans = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  printf("%lld\n", ans);
}
signed main() {
  scanf("%lld%s", &n, s + 1), pw[0] = iv[0] = 1;
  for (long long i = 1; i <= n; i++)
    pw[i] = pw[i - 1] * bse % mod, iv[i] = iv[i - 1] * inv % mod,
    lg[i] = lg[i >> 1] + 1;
  for (long long i = 1; i < n; i++)
    scanf("%lld%lld", &x, &y), add(x, y), add(y, x);
  dfs(1, 0);
  dfs(1, 0, 1);
  scanf("%lld", &m);
  for (long long i = 1; i <= m; i++)
    scanf("%lld%lld%lld%lld", &x, &y, &a, &b), solve(x, y, a, b);
}