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;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return f == 1 ? x : -x;
}
const int N = 3e5 + 4, mod = 1e9 + 713, B = 317;
int n, tim, dep[N], fa[N][20], d[N], h1[N], h2[N], st[N], a[N << 1], son[N],
    pw[N], top[N], mn[N << 1][20], lg[N << 1];
char s[N];
vector<int> e[N], fu[N], fv[N];
void dfs_1(int x) {
  dep[x] = d[x] = d[fa[x][0]] + 1;
  h1[x] = ((long long)h1[fa[x][0]] * B + s[x]) % mod;
  h2[x] = ((long long)s[x] * pw[d[x] - 1] + h2[fa[x][0]]) % mod;
  for (int i = 1; (1ll << i) <= d[x]; i++) fa[x][i] = fa[fa[x][i - 1]][i - 1];
  st[x] = ++tim;
  a[tim] = x;
  for (auto v : e[x]) {
    if (v == fa[x][0]) continue;
    fa[v][0] = x;
    dfs_1(v);
    a[++tim] = x;
    if (dep[v] > dep[x]) {
      dep[x] = dep[v];
      son[x] = v;
    }
  }
}
void dfs_2(int x, int tp) {
  top[x] = tp;
  if (x == tp) {
    for (int i = 0, ou = x, ov = x; i <= dep[x] - d[x];
         i++, ou = fa[ou][0], ov = son[ov]) {
      fu[x].push_back(ou);
      fv[x].push_back(ov);
    }
  }
  if (son[x]) dfs_2(son[x], tp);
  for (auto v : e[x])
    if (v != fa[x][0] && v != son[x]) dfs_2(v, v);
}
inline int kthfa(int x, int k) {
  if (!k) return x;
  x = fa[x][lg[k]];
  k -= 1 << lg[k];
  k -= d[x] - d[top[x]];
  x = top[x];
  return k >= 0 ? fu[x][k] : fv[x][-k];
}
inline int cmp(int x, int y) { return d[a[x]] < d[a[y]] ? x : y; }
inline void prepare() {
  for (int i = 2; i <= tim; i++) lg[i] = lg[i >> 1] + 1;
  for (int i = 1; i <= tim; i++) mn[i][0] = i;
  for (int j = 1; (1 << j) <= tim; j++)
    for (int i = 1; i + (1 << j - 1) <= tim; i++)
      mn[i][j] = cmp(mn[i][j - 1], mn[i + (1 << j - 1)][j - 1]);
}
inline int getlca(int u, int v) {
  u = st[u];
  v = st[v];
  if (u > v) u ^= v ^= u ^= v;
  int k = lg[v - u + 1];
  return a[cmp(mn[u][k], mn[v - (1 << k) + 1][k])];
}
inline int hsh(int u, int lca, int v, int dis) {
  int x;
  if (d[u] - d[lca] >= dis) {
    x = kthfa(u, dis);
    return (long long)pw[n - dis - d[x]] * (h2[u] - h2[x] + mod) % mod;
  }
  x = kthfa(v, d[u] + d[v] - d[lca] * 2 + 1 - dis);
  return ((long long)pw[n - dis + d[x] - d[lca] * 2 + 1] *
              (h2[u] - h2[lca] + mod) +
          (long long)(h1[x] -
                      (long long)h1[fa[lca][0]] * pw[d[x] - d[lca] + 1] % mod +
                      mod) *
              pw[n - dis]) %
         mod;
}
int main() {
  n = read();
  scanf("%s", s + 1);
  for (int i = 1, u, v; i < n; i++) {
    u = read();
    v = read();
    e[u].push_back(v);
    e[v].push_back(u);
  }
  pw[0] = 1;
  for (int i = 1; i <= n; i++) pw[i] = (long long)pw[i - 1] * B % mod;
  dfs_1(1);
  dfs_2(1, 1);
  prepare();
  for (int Q = read(), u1, v1, u2, v2, l1, l2, l, r, mid; Q--;) {
    u1 = read();
    v1 = read();
    u2 = read();
    v2 = read();
    l1 = getlca(u1, v1);
    l2 = getlca(u2, v2);
    l = 0;
    r = min(d[u1] + d[v1] - d[l1] * 2 + 1, d[u2] + d[v2] - d[l2] * 2 + 1);
    while (l < r) {
      mid = (l + r + 1) >> 1;
      if (hsh(u1, l1, v1, mid) == hsh(u2, l2, v2, mid))
        l = mid;
      else
        r = mid - 1;
    }
    cout << r << "\n";
  }
  return (0 - 0);
}