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;
template <typename T>
inline void Read(T &x) {
  int f = 1;
  char t = getchar();
  while (t < '0' || t > '9') {
    if (t == '-') f = -1;
    t = getchar();
  }
  x = 0;
  while (t >= '0' && t <= '9') {
    x = x * 10 + t - '0';
    t = getchar();
  }
  x *= f;
}
template <typename T>
inline void Write(T x) {
  static int output[20];
  int top = 0;
  if (x < 0) putchar('-'), x = -x;
  do {
    output[++top] = x % 10;
    x /= 10;
  } while (x > 0);
  while (top > 0) putchar('0' + output[top--]);
  putchar('\n');
}
template <typename T>
inline void chkmin(T &x, T y) {
  if (x > y) x = y;
}
template <typename T>
inline void chkmax(T &x, T y) {
  if (x < y) x = y;
}
const int maxn = 300005;
const int modulo = 1e9 + 7;
const int seed = 29;
int n;
int m;
char str[maxn];
int fst[maxn];
int v[maxn << 1], nxt[maxn << 1];
int e_cn;
int id[maxn];
int fa[maxn];
int up[maxn];
int top[maxn];
int dep[maxn];
int son[maxn];
int size[maxn];
int counter;
int hash_e[maxn];
int hash_r[maxn];
int pw[maxn];
void addedge(int x, int y) {
  e_cn++, v[e_cn] = y;
  nxt[e_cn] = fst[x], fst[x] = e_cn;
}
void input() {
  Read(n);
  scanf("%s", str + 1);
  for (int i = 1; i < n; i++) {
    int x, y;
    Read(x);
    Read(y);
    addedge(x, y);
    addedge(y, x);
  }
  Read(m);
}
void dfs1(int cn, int pr) {
  size[cn] = 1;
  son[cn] = -1;
  fa[cn] = pr;
  for (int i = fst[cn]; i; i = nxt[i]) {
    if (v[i] != pr) {
      dep[v[i]] = dep[cn] + 1;
      dfs1(v[i], cn);
      size[cn] += size[v[i]];
      if (son[cn] == -1 || size[v[i]] > size[son[cn]]) {
        son[cn] = v[i];
      }
    }
  }
}
void dfs2(int cn, int pr) {
  if (son[cn] != -1) {
    top[son[cn]] = top[cn];
    up[son[cn]] = ++counter;
    id[counter] = son[cn];
    hash_e[counter] = str[son[cn]] - 'a' + 1;
    dfs2(son[cn], cn);
  }
  for (int i = fst[cn]; i; i = nxt[i]) {
    if (v[i] != pr && v[i] != son[cn]) {
      top[v[i]] = v[i];
      up[v[i]] = ++counter;
      id[counter] = v[i];
      hash_e[counter] = str[v[i]] - 'a' + 1;
      dfs2(v[i], cn);
    }
  }
}
void prepare() {
  addedge(0, 1);
  dfs1(0, 0);
  dfs2(0, 0);
  memcpy(hash_r, hash_e, sizeof(hash_e));
  reverse(hash_r + 1, hash_r + counter + 1);
  for (int i = 1; i <= counter; i++) {
    hash_e[i] = (1ll * hash_e[i - 1] * seed % modulo + hash_e[i]) % modulo;
    hash_r[i] = (1ll * hash_r[i - 1] * seed % modulo + hash_r[i]) % modulo;
  }
  pw[0] = 1;
  for (int i = 1; i <= counter; i++) {
    pw[i] = 1ll * pw[i - 1] * seed % modulo;
  }
}
inline int gethash(int *res, int l, int r) {
  return (res[r] - 1ll * res[l - 1] * pw[r - l + 1] % modulo + modulo) % modulo;
}
inline int climb(int x, int step) {
  int del;
  while ((del = dep[x] - dep[top[x]] + 1) <= step) {
    step -= del;
    x = fa[top[x]];
  }
  x = up[x];
  return id[x - step];
}
inline int lca(int x, int y) {
  int t1 = top[x];
  int t2 = top[y];
  while (t1 != t2) {
    if (dep[t1] < dep[t2]) {
      swap(x, y);
      swap(t1, t2);
    }
    x = fa[t1], t1 = top[x];
  }
  if (dep[x] > dep[y]) swap(x, y);
  return x;
}
inline int query_e(int x, int step) {
  int res = 0;
  int del;
  while ((del = dep[x] - dep[top[x]] + 1) <= step) {
    res =
        (1ll * res * pw[del] % modulo + gethash(hash_r, (counter - (up[x]) + 1),
                                                (counter - (up[top[x]]) + 1))) %
        modulo;
    x = fa[top[x]];
    step -= del;
  }
  if (step > 0) {
    res = (1ll * res * pw[step] % modulo +
           gethash(hash_r, (counter - (up[x]) + 1),
                   (counter - (up[x] - step + 1) + 1))) %
          modulo;
  }
  return res;
}
inline int query_r(int x, int step) {
  int res = 0;
  int del;
  int now = 0;
  while ((del = dep[x] - dep[top[x]] + 1) <= step) {
    res = (res + 1ll * gethash(hash_e, up[top[x]], up[x]) * pw[now] % modulo) %
          modulo;
    x = fa[top[x]];
    step -= del;
    now += del;
  }
  if (step > 0) {
    res = (res +
           1ll * gethash(hash_e, up[x] - step + 1, up[x]) * pw[now] % modulo) %
          modulo;
  }
  return res;
}
inline int strhash(int x, int y, int g, int len) {
  int d1 = dep[x] - dep[g] + 1;
  int d2 = dep[y] - dep[g];
  if (len <= d1) {
    return query_e(x, len);
  } else {
    return (1ll * query_e(x, d1) * pw[len - d1] % modulo +
            query_r(climb(y, d1 + d2 - len), len - d1)) %
           modulo;
  }
}
int lcp(int a, int b, int c, int d) {
  int t1 = lca(a, b);
  int t2 = lca(c, d);
  int l = 0;
  int r =
      min(dep[a] + dep[b] - 2 * dep[t1] + 1, dep[c] + dep[d] - 2 * dep[t2] + 1);
  int mid;
  int res = 0;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (strhash(a, b, t1, mid) == strhash(c, d, t2, mid)) {
      res = mid;
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  return res;
}
void solve() {
  int a, b, c, d;
  for (int i = 1; i <= m; i++) {
    Read(a);
    Read(b);
    Read(c);
    Read(d);
    printf("%d\n", lcp(a, b, c, d));
  }
}
int main() {
  input();
  prepare();
  solve();
  return 0;
}