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>
#pragma GCC optimize(2)
using namespace std;
const int mod = 1000000007;
struct node {
  int l, r;
} s[2][300002], tmp1[300002], tmp2[300002];
struct Hash {
  long long h1, h2;
} Mod, p[300002], H1[300002], H2[300002];
Hash operator+(Hash a, Hash b) {
  return (Hash){(a.h1 + b.h1) % mod, (a.h2 + b.h2) % mod};
}
Hash operator-(Hash a, Hash b) {
  return (Hash){(a.h1 - b.h1 + mod) % mod, (a.h2 - b.h2 + mod) % mod};
}
Hash operator*(Hash a, Hash b) {
  return (Hash){a.h1 * b.h1 % mod, a.h2 * b.h2 % mod};
}
bool operator==(Hash a, Hash b) { return (a.h1 == b.h1 && a.h2 == b.h2); }
int head[300002], ver[300002 * 2], nxt[300002 * 2], l;
int n, m, i, j, a[300002], size[300002], son[300002], fa[300002], dep[300002],
    top[300002], dfn[300002], cnt, num[2];
char c[300002];
int read() {
  char c = getchar();
  int w = 0;
  while (c < '0' || c > '9') c = getchar();
  while (c <= '9' && c >= '0') {
    w = w * 10 + c - '0';
    c = getchar();
  }
  return w;
}
void insert(int x, int y) {
  l++;
  ver[l] = y;
  nxt[l] = head[x];
  head[x] = l;
}
void dfs1(int x, int pre) {
  dep[x] = dep[pre] + 1;
  size[x] = 1;
  fa[x] = pre;
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (y != pre) {
      dfs1(y, x);
      size[x] += size[y];
      if (size[y] > size[son[x]]) son[x] = y;
    }
  }
}
void dfs2(int x, int t) {
  top[x] = t;
  dfn[x] = ++cnt;
  a[cnt] = c[x] - 'a';
  if (son[x]) dfs2(son[x], t);
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (y != fa[x] && y != son[x]) dfs2(y, y);
  }
}
int LCA(int u, int v) {
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    u = fa[top[u]];
  }
  if (dep[u] > dep[v]) swap(u, v);
  return u;
}
void divide(int p, int u, int v) {
  int lca = LCA(u, v), l1 = 0, l2 = 0;
  while (dep[top[u]] > dep[lca])
    tmp1[++l1] = (node){dfn[u], dfn[top[u]]}, u = fa[top[u]];
  tmp1[++l1] = (node){dfn[u], dfn[lca]};
  while (dep[top[v]] > dep[lca])
    tmp2[++l2] = (node){dfn[top[v]], dfn[v]}, v = fa[top[v]];
  if (v != lca) tmp2[++l2] = (node){dfn[son[lca]], dfn[v]};
  for (int i = 1; i <= l1; i++) s[p][++num[p]] = tmp1[i];
  for (int i = l2; i >= 1; i--) s[p][++num[p]] = tmp2[i];
}
Hash get(int op, node s, int len) {
  if (op == 0)
    return H1[s.l + len - 1] - H1[s.l - 1] * p[len];
  else
    return H2[s.l - len + 1] - H2[s.l + 1] * p[len];
}
int main() {
  n = read();
  scanf("%s", c + 1);
  for (i = 1; i < n; i++) {
    int u = read(), v = read();
    insert(u, v);
    insert(v, u);
  }
  dfs1(1, 0);
  dfs2(1, 1);
  Mod = (Hash){131, 13331};
  p[0] = (Hash){0, 0};
  p[1] = Mod;
  for (i = 2; i <= n; i++) p[i] = p[i - 1] * Mod;
  for (i = 1; i <= n; i++) H1[i] = H1[i - 1] * Mod + (Hash){a[i], a[i]};
  for (i = n; i >= 1; i--) H2[i] = H2[i + 1] * Mod + (Hash){a[i], a[i]};
  m = read();
  while (m--) {
    int a = read(), b = read(), c = read(), d = read(), ans = 0;
    num[0] = num[1] = 0;
    divide(0, a, b);
    divide(1, c, d);
    i = j = 1;
    while (i <= num[0] && j <= num[1]) {
      int op1 = (s[0][i].r < s[0][i].l), op2 = (s[1][j].r < s[1][j].l);
      int len1 = abs(s[0][i].r - s[0][i].l) + 1,
          len2 = abs(s[1][j].r - s[1][j].l) + 1, len = min(len1, len2);
      Hash hash1 = get(op1, s[0][i], len), hash2 = get(op2, s[1][j], len);
      if (hash1 == hash2) {
        if (len == len1)
          i++;
        else {
          if (op1 == 0)
            s[0][i].l += len;
          else
            s[0][i].l -= len;
        }
        if (len == len2)
          j++;
        else {
          if (op2 == 0)
            s[1][j].l += len;
          else
            s[1][j].l -= len;
        }
        ans += len;
      } else {
        int l = 1, r = len, mid, res = 0;
        while (l <= r) {
          mid = (l + r) / 2;
          if (get(op1, s[0][i], mid) == get(op2, s[1][j], mid))
            res = mid, l = mid + 1;
          else
            r = mid - 1;
        }
        ans += res;
        break;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}