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;
int p1 = 1000000, p2 = 0;
char buf[1000005], wb[1000005];
int getint() {
  int ret = 0, flag = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') flag = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') {
    ret = (ret << 3) + (ret << 1) + c - '0';
    c = getchar();
  }
  return ret * flag;
}
void pc(char x) {
  if (p2 >= 1000000) fwrite(wb, 1, 1000000, stdout), p2 = 0;
  wb[p2++] = x;
}
void wrt(int x) {
  if (x < 0) pc('-'), x = -x;
  int c[24] = {0};
  if (!x) return pc('0'), void();
  while (x) c[++c[0]] = x % 10, x /= 10;
  while (c[0]) pc(c[c[0]--] + '0');
}
int n, m, ans;
struct edge {
  int ne, v;
} e[600005];
int head[300005], cnt;
void add(int u, int v) {
  ++cnt;
  e[cnt].v = v;
  e[cnt].ne = head[u];
  head[u] = cnt;
}
int dep[300005], md[300005], son[300005];
int p[300005][20];
void dfs1(int x, int prt) {
  dep[x] = dep[prt] + 1;
  md[x] = dep[x];
  p[x][0] = prt;
  for (int i = 1; i < 20; i++) p[x][i] = p[p[x][i - 1]][i - 1];
  for (int i = head[x]; i; i = e[i].ne) {
    int y = e[i].v;
    if (y == prt) continue;
    dfs1(y, x);
    if (md[x] < md[y]) son[x] = y, md[x] = md[y];
  }
}
int tp[300005], len[300005];
void dfs2(int x, int prt, int top) {
  tp[x] = top;
  len[x] = md[x] - dep[top] + 1;
  if (son[x]) dfs2(son[x], x, top);
  for (int i = head[x]; i; i = e[i].ne) {
    int y = e[i].v;
    if (y == prt || y == son[x]) continue;
    dfs2(y, x, y);
  }
}
int hbit[300005];
vector<int> up[300005], dw[300005];
int get_kth(int x, int k) {
  if (k > dep[x]) return 0;
  if (!k) return x;
  x = p[x][hbit[k]];
  k ^= 1 << hbit[k];
  if (!k) return x;
  if (dep[x] - dep[tp[x]] == k) return tp[x];
  if (dep[x] - dep[tp[x]] > k) return dw[tp[x]][dep[x] - dep[tp[x]] - k - 1];
  if (dep[x] - dep[tp[x]] < k) return up[tp[x]][k - dep[x] + dep[tp[x]] - 1];
  return 0;
}
char c[300005];
int pw[300005], invp[300005], h1[300005], h2[300005];
int ksm(int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1) ret = 1ll * ret * a % 998244353;
    a = 1ll * a * a % 998244353;
    b >>= 1;
  }
  return ret;
}
void dfs(int x, int prt, int dep) {
  h1[x] = (1ll * h1[prt] * 233 + c[x]) % 998244353;
  h2[x] = (1ll * pw[dep] * c[x] + h2[prt]) % 998244353;
  for (int i = head[x]; i; i = e[i].ne) {
    int y = e[i].v;
    if (y == prt) continue;
    dfs(y, x, dep + 1);
  }
}
int LCA(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = log2(dep[x] - dep[y]); i >= 0; i--) {
    if (dep[p[x][i]] >= dep[y]) x = p[x][i];
  }
  if (x == y) return x;
  for (int i = log2(dep[x]); i >= 0; i--) {
    if (p[x][i] ^ p[y][i]) x = p[x][i], y = p[y][i];
  }
  return p[x][0];
}
int cal(int u, int v, int lca, int len) {
  int ret = 0, flca = p[lca][0];
  if (dep[u] - dep[lca] + 1 <= len) {
    int goal =
        get_kth(v, (dep[v] - dep[lca]) - (len - (dep[u] - dep[flca])) - 1);
    ret = 1ll * (h2[u] - h2[flca] + 998244353) % 998244353 * invp[dep[flca]] %
          998244353;
    ret = 1ll * ret * pw[(len - (dep[u] - dep[flca])) + 1] % 998244353;
    ret = (ret +
           (h1[goal] - 1ll * h1[lca] * pw[dep[goal] - dep[lca]] % 998244353 +
            998244353) %
               998244353) %
          998244353;
  } else {
    int goal = get_kth(u, len + 1);
    ret = 1ll * (h2[u] - h2[goal] + 998244353) % 998244353 * invp[dep[goal]] %
          998244353;
  }
  return ret;
}
int main() {
  pw[0] = 1;
  invp[0] = 1;
  n = getint();
  scanf("%s", c + 1);
  for (int i = 1; i <= n; i++)
    pw[i] = 1ll * pw[i - 1] * 233 % 998244353,
    invp[i] = 1ll * invp[i - 1] * 844009174 % 998244353;
  for (int i = 1; i < n; i++) {
    int u = getint(), v = getint();
    add(u, v);
    add(v, u);
  }
  dfs(1, 0, 0);
  dfs1(1, 0);
  dfs2(1, 0, 1);
  for (int i = 1; i <= n; i++) {
    if (i == tp[i]) {
      int k, x;
      k = 0, x = i;
      while (k++ < len[i] && x) x = p[x][0], up[i].push_back(x);
      k = 0, x = i;
      while (k++ < len[i] && x) x = son[x], dw[i].push_back(x);
    }
  }
  for (int i = 2; i <= n; i++) hbit[i] = hbit[i >> 1] + 1;
  m = getint();
  for (int i = 1; i <= m; i++) {
    int u1 = getint(), v1 = getint(), u2 = getint(), v2 = getint();
    int lca1 = LCA(u1, v1), lca2 = LCA(u2, v2);
    int l = 0, r = min(dep[u1] + dep[v1] - dep[lca1] * 2,
                       dep[u2] + dep[v2] - dep[lca2] * 2);
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (cal(u1, v1, lca1, mid) == cal(u2, v2, lca2, mid))
        l = mid + 1;
      else
        r = mid - 1;
    }
    wrt(l), pc('\n');
  }
  fwrite(wb, 1, p2, stdout);
  return 0;
}