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;
char nc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
void Read(int& x) {
  char c = nc();
  for (; c < '0' || c > '9'; c = nc())
    ;
  for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - 48, c = nc())
    ;
}
const int N = 300010;
const int M = 19;
int k, n, m;
int Rt = 1, lst = 1, nx[N << 2][26], link[N << 2], len[N << 2], cnt = 1;
int h[N], nxt[N << 1], t[N << 1], num;
int f[N], d[N], son[N], sz[N], top[N];
int F[N][M];
int w[2][N];
int w2[N << 1];
int x, y, tot;
int c[N], L[2][N], R[2][N], l[2];
int a1[N], a2[N], l1, l2;
char s[N], S[N << 1];
int Top[N << 2], Son[N << 2], Sz[N << 2];
vector<int> g[N << 2];
int Abs(int x) { return x > 0 ? x : -x; }
void Add(int x, int y) {
  t[++num] = y;
  nxt[num] = h[x];
  h[x] = num;
}
void Dfs(int x, int y) {
  f[x] = F[x][0] = y;
  d[x] = d[y] + 1;
  sz[x] = 1;
  for (int i = 1; i < M; i++) F[x][i] = F[F[x][i - 1]][i - 1];
  for (int i = h[x]; i; i = nxt[i])
    if (t[i] != y) {
      Dfs(t[i], x);
      sz[x] += sz[t[i]];
      if (sz[t[i]] > sz[son[x]]) son[x] = t[i];
    }
}
void Dfs1(int x, int y) {
  top[x] = y;
  if (!son[x]) {
    int l = 0;
    for (int i = x; f[top[x]] != i; i = f[i]) c[++l] = i;
    for (int i = 1; i <= l; i++) {
      S[++tot] = s[c[i]];
      w2[tot] = c[i];
    }
    for (int i = l; i; i--) {
      S[++tot] = s[c[i]];
      w2[tot] = -c[i];
    }
    return;
  }
  Dfs1(son[x], y);
  for (int i = h[x]; i; i = nxt[i])
    if (t[i] != f[x] && t[i] != son[x]) Dfs1(t[i], t[i]);
}
void Dfs2(int x) {
  Sz[x] = 1;
  for (int i = 0; i < g[x].size(); i++) {
    int v = g[x][i];
    Dfs2(v);
    Sz[x] += Sz[v];
    if (Sz[v] > Sz[Son[x]]) Son[x] = v;
  }
}
void Dfs3(int x, int y) {
  Top[x] = y;
  if (Son[x]) Dfs3(Son[x], y);
  for (int i = 0; i < g[x].size(); i++)
    if (g[x][i] != Son[x]) Dfs3(g[x][i], g[x][i]);
}
int Lca(int x, int y) {
  while (Top[x] != Top[y])
    if (len[Top[x]] > len[Top[y]])
      x = link[Top[x]];
    else
      y = link[Top[y]];
  return min(len[x], len[y]);
}
int Extend(int x) {
  int np = ++cnt;
  len[np] = len[lst] + 1;
  int p = lst;
  for (; p && !nx[p][x]; p = link[p]) nx[p][x] = np;
  if (!p)
    link[np] = 1;
  else {
    int q = nx[p][x];
    if (len[q] == len[p] + 1)
      link[np] = q;
    else {
      int nq = ++cnt;
      link[nq] = link[q];
      link[q] = link[np] = nq;
      memcpy(nx[nq], nx[q], sizeof(nx[q]));
      len[nq] = len[p] + 1;
      for (; p && nx[p][x] == q; p = link[p]) nx[p][x] = nq;
    }
  }
  return lst = np;
}
void init() {
  Read(n);
  char C = nc();
  for (; C < 'a' || C > 'z'; C = nc())
    ;
  for (int i = 1; i <= n; i++) s[i] = C, C = nc();
  for (int i = 1; i < n; i++) Read(x), Read(y), Add(x, y), Add(y, x);
  Dfs(1, 0);
  Dfs1(1, 1);
  for (int i = tot; i; i--) {
    x = Extend(S[i] - 'a');
    if (w2[i] > 0)
      w[0][w2[i]] = x;
    else
      w[1][-w2[i]] = x;
  }
  for (int i = 2; i <= cnt; i++) g[link[i]].push_back(i);
  Dfs2(1);
  Dfs3(1, 1);
}
void Get(int x, int y, bool b) {
  a1[l1 = 1] = x;
  a2[l2 = 1] = y;
  while (top[x] != top[y])
    if (d[top[x]] > d[top[y]])
      a1[++l1] = top[x], x = f[top[x]];
    else
      a2[++l2] = top[y], y = f[top[y]];
  l[b] = 0;
  for (int i = 1; i < l1; i++)
    L[b][++l[b]] = i == 1 ? a1[i] : f[a1[i]], R[b][l[b]] = a1[i + 1];
  L[b][++l[b]] = l1 == 1 ? x : f[a1[l1]];
  R[b][l[b]] = l2 == 1 ? a2[l2] : f[a2[l2]];
  for (int i = l2; i > 1; i--)
    L[b][++l[b]] = a2[i], R[b][l[b]] = i == 2 ? a2[i - 1] : f[a2[i - 1]];
}
int Find(int x, int k) {
  for (int i = M - 1; ~i; i--)
    if ((1 << i) <= k) x = F[x][i], k -= 1 << i;
  return x;
}
int Ask(int l1, int r1, int l2, int r2) {
  return Lca(w[(d[r1] > d[l1])][l1], w[(d[r2] > d[l2])][l2]);
}
int Query() {
  int id[2], cur[2];
  cur[0] = L[0][1];
  cur[1] = L[1][1];
  id[0] = id[1] = 1;
  int Ans = 0;
  while (id[0] <= l[0] && id[1] <= l[1]) {
    bool b = 0, B = 1;
    if (Abs(d[R[b][id[b]]] - d[cur[b]]) > Abs(d[R[B][id[B]]] - d[cur[B]]))
      swap(b, B);
    int t = Ask(cur[b], R[b][id[b]], cur[B], R[B][id[B]]),
        tmp = Abs(d[R[b][id[b]]] - d[cur[b]]) + 1;
    if (t < tmp) return Ans + t;
    Ans += tmp;
    cur[b] = L[b][++id[b]];
    if (Abs(d[R[B][id[B]]] - d[cur[B]]) + 1 == tmp)
      cur[B] = L[B][++id[B]];
    else if (d[L[B][id[B]]] > d[R[B][id[B]]])
      cur[B] = Find(cur[B], tmp);
    else
      cur[B] = Find(R[B][id[B]], d[R[B][id[B]]] - d[cur[B]] - tmp);
  }
  return Ans;
}
int main() {
  init();
  Read(m);
  while (m--) {
    Read(x);
    Read(y);
    Get(x, y, 0);
    Read(x);
    Read(y);
    Get(x, y, 1);
    printf("%d\n", Query());
  }
  return 0;
}