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 double pi = acos(-1);
const int mo = 1000010029, p1 = 137, ni_p1 = 131388179;
char c[310000];
int Pow[310000], ni_Pow[310000], h1[310000], h2[310000];
int size[310000], dep[310000], fa[310000], dfn[310000], tim, q[310000], n, Q;
int su[310000];
vector<int> E[310000];
struct ppp {
  int x, len, s;
};
ppp make_pair(int x, int len, int s) { return ppp{x, len, s}; }
void prep(int x, int fa) {
  h1[x] = (1ll * h1[fa] * p1 + c[x]) % mo;
  h2[x] = (h2[fa] + 1ll * Pow[dep[x]] * c[x]) % mo;
  size[x] = 1;
  for (int i : E[x])
    if (i != fa) {
      dep[i] = dep[x] + 1;
      prep(i, x);
      size[x] += size[i];
    }
}
void dfs(int x, int ff) {
  fa[x] = ff;
  int maxx = -1;
  dfn[x] = ++tim;
  q[tim] = x;
  for (int i : E[x])
    if (i != ff && (maxx == -1 || size[i] > size[maxx])) maxx = i;
  if (maxx != -1) {
    su[maxx] = su[x];
    dfs(maxx, x);
  }
  for (int i : E[x])
    if (i != ff && i != maxx) {
      su[i] = i;
      dfs(i, x);
    }
}
void work(int x, int y, vector<ppp> &t, int &lca) {
  vector<ppp> tmp;
  for (;;) {
    if (su[x] == su[y]) {
      if (dfn[x] < dfn[y])
        tmp.push_back(make_pair(dfn[x], dfn[y] - dfn[x] + 1, 1)), lca = x;
      else
        t.push_back(make_pair(dfn[x], dfn[x] - dfn[y] + 1, -1)), lca = y;
      break;
    }
    if (dfn[x] > dfn[y]) {
      t.push_back(make_pair(dfn[x], dfn[x] - dfn[su[x]] + 1, -1));
      x = fa[su[x]];
    } else {
      tmp.push_back(make_pair(dfn[su[y]], dfn[y] - dfn[su[y]] + 1, 1));
      y = fa[su[y]];
    }
  }
  if (tmp.size())
    for (int i = tmp.size() - 1; i >= 0; --i) t.push_back(tmp[i]);
}
int Geth(int x, int y, int lca) {
  if (lca == -1) lca = y;
  int d1 = dep[x] - dep[lca];
  return ((h1[x] - 1ll * h1[lca] * Pow[d1] +
           1ll * (h2[y] - h2[fa[lca]]) * ni_Pow[dep[lca]] % mo * Pow[d1]) %
              mo +
          mo) %
         mo;
}
int main() {
  scanf("%d", &n);
  scanf("%s", c + 1);
  Pow[0] = 1;
  ni_Pow[0] = 1;
  for (int i = 1; i <= n; ++i) {
    Pow[i] = 1ll * Pow[i - 1] * p1 % mo;
    ni_Pow[i] = 1ll * ni_Pow[i - 1] * ni_p1 % mo;
  }
  for (int i = 1; i <= n - 1; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    E[x].push_back(y);
    E[y].push_back(x);
  }
  prep(1, 0);
  su[1] = 1;
  dfs(1, 0);
  scanf("%d", &Q);
  for (int _ = 1; _ <= Q; ++_) {
    int u, v, x, y;
    scanf("%d%d%d%d", &x, &y, &u, &v);
    vector<ppp> t1, t2;
    int lca1, lca2;
    work(x, y, t1, lca1);
    work(u, v, t2, lca2);
    int len1 = t1.size(), len2 = t2.size(), p1 = 0, p2 = 0, l1 = 0, l2 = 0,
        ans = 0, d1, d2;
    while (p1 < len1 && p2 < len2) {
      int len = min(t1[p1].len - l1, t2[p2].len - l2);
      d1 = t1[p1].s;
      d2 = t2[p2].s;
      if (Geth(x, q[t1[p1].x + (l1 + len - 1) * d1], d1 == -1 ? -1 : lca1) !=
          Geth(u, q[t2[p2].x + (l2 + len - 1) * d2], d2 == -1 ? -1 : lca2))
        break;
      l1 += len;
      l2 += len;
      if (l1 >= t1[p1].len) p1++, l1 = 0;
      if (l2 >= t2[p2].len) p2++, l2 = 0;
      ans += len;
    }
    if (p1 >= len1 || p2 >= len2) {
      printf("%d\n", ans);
      continue;
    }
    int maxlen = min(t1[p1].len - l1, t2[p2].len - l2);
    for (int i = 20; i >= 0; --i)
      if (maxlen >= 1 << i) {
        if (Geth(x, q[t1[p1].x + (l1 + (1 << i) - 1) * d1],
                 d1 == -1 ? -1 : lca1) ==
            Geth(u, q[t2[p2].x + (l2 + (1 << i) - 1) * d2],
                 d2 == -1 ? -1 : lca2)) {
          maxlen -= 1 << i;
          l1 += 1 << i;
          l2 += 1 << i;
          ans += 1 << i;
        }
      }
    printf("%d\n", ans);
  }
}