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 int MAXN = 300005;
long long q_pow(long long a, long long b, long long p) {
  long long ret = 1;
  for (; b; a = a * a % p, b >>= 1)
    if (b & 1) ret = ret * a % p;
  return ret;
}
long long inv(long long x, long long p) { return q_pow(x, p - 2, p); }
long long dec(long long x, long long y, long long p) {
  return x < y ? x - y + p : x - y;
}
int N, M;
char S[MAXN];
struct node {
  int v, next;
} E[MAXN << 1];
int head[MAXN], Elen;
void add(int u, int v) {
  ++Elen, E[Elen].v = v, E[Elen].next = head[u], head[u] = Elen;
}
const int m1 = 998244353, m2 = 1000000007;
long long p1[MAXN], p2[MAXN], i1[MAXN], i2[MAXN];
void init() {
  p1[0] = p2[0] = i1[0] = i2[0] = 1;
  int inv1 = inv(97, m1), inv2 = inv(101, m2);
  for (int i = 1; i <= N; ++i) {
    p1[i] = p1[i - 1] * 97 % m1, i1[i] = i1[i - 1] * inv1 % m1;
    p2[i] = p2[i - 1] * 101 % m2, i2[i] = i2[i - 1] * inv2 % m2;
  }
}
struct has {
  int len;
  long long x, y;
  has(long long x = 0, long long y = 0, int len = 0) : x(x), y(y), len(len) {}
  has(char ch) : x(ch - 'a'), y(ch - 'a') { len = 1; }
  has operator+(has T) {
    return has((x * p1[T.len] + T.x) % m1, (y * p2[T.len] + T.y) % m2,
               len + T.len);
  }
  bool operator==(has T) { return x == T.x && y == T.y && len == T.len; }
  friend has dec2(has l, has r) {
    return has(dec(l.x, r.x, m1) * i1[r.len] % m1,
               dec(l.y, r.y, m2) * i2[r.len] % m2, l.len - r.len);
  }
  friend has dec1(has l, has r) {
    return has(dec(l.x, r.x * p1[l.len - r.len] % m1, m1),
               dec(l.y, r.y * p2[l.len - r.len] % m2, m2), l.len - r.len);
  }
} s1[MAXN], s2[MAXN];
int fa[MAXN], dep[MAXN], siz[MAXN], wson[MAXN], top[MAXN], dfn[MAXN],
    idfn[MAXN], dfncnt;
void dfs1(int u, int ff) {
  fa[u] = ff, dep[u] = dep[ff] + 1, siz[u] = 1;
  s1[u] = s1[ff] + has(S[u]), s2[u] = has(S[u]) + s2[ff];
  for (int i = head[u]; i; i = E[i].next)
    if (E[i].v != ff) {
      dfs1(E[i].v, u), siz[u] += siz[E[i].v];
      if (siz[wson[u]] < siz[E[i].v]) wson[u] = E[i].v;
    }
}
void dfs2(int u, int ff, int tp) {
  top[u] = tp, dfn[u] = ++dfncnt, idfn[dfncnt] = u;
  if (wson[u]) dfs2(wson[u], u, tp);
  for (int i = head[u]; i; i = E[i].next)
    if (E[i].v != ff && E[i].v != wson[u]) {
      dfs2(E[i].v, u, E[i].v);
    }
}
int lca(int u, int v) {
  while (top[u] != top[v]) {
    if (dep[fa[top[u]]] < dep[fa[top[v]]]) swap(u, v);
    u = fa[top[u]];
  }
  if (dep[u] > dep[v]) swap(u, v);
  return u;
}
int anc(int u, int k) {
  while (u && k >= dep[u] - dep[fa[top[u]]]) {
    k -= dep[u] - dep[fa[top[u]]], u = fa[top[u]];
  }
  return u ? idfn[dfn[u] - k] : 0;
}
int dis(int u, int v) { return dep[u] + dep[v] - 2 * dep[lca(u, v)]; }
int dis(int u, int v, int lc) { return dep[u] + dep[v] - 2 * dep[lc]; }
has treehash(int u, int v, int lc, int k) {
  int du = dep[u] - dep[lc], dv = dep[v] - dep[lc];
  if (k - 1 <= du)
    return dec2(s2[u], s2[anc(u, k)]);
  else
    return dec2(s2[u], s2[lc]) + has(S[lc]) +
           dec1(s1[anc(v, dv - (k - du - 1))], s1[lc]);
}
int main() {
  scanf("%d%s", &N, S + 1);
  int u, v, a, b, ab, c, d, cd;
  for (int i = 1; i < N; ++i) scanf("%d%d", &u, &v), add(u, v), add(v, u);
  init();
  dfs1(1, 0), dfs2(1, 0, 1);
  scanf("%d", &M);
  while (M--) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int ab = lca(a, b), cd = lca(c, d);
    int lb = 1, rb = min(dis(a, b, ab), dis(c, d, cd)) + 1, mid, ans = 0;
    while (lb <= rb) {
      mid = (lb + rb) >> 1;
      if (treehash(a, b, ab, mid) == treehash(c, d, cd, mid)) {
        lb = mid + 1, ans = mid;
      } else
        rb = mid - 1;
    }
    printf("%d\n", ans);
  }
  return 0;
}