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 Maxx = 1000001, Maxn = 2001, INF = 0x3f3f3f3f, Mod = 998244353;
inline int read() {
  int res = 0, bj = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') bj |= (ch == '-'), ch = getchar();
  while (ch >= '0' && ch <= '9')
    res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
  return bj ? -res : res;
}
void print(int x) {
  if (x > 9) print(x / 10);
  putchar(x % 10 ^ 48);
}
inline void printnum(int x, char ch) {
  if (x < 0) putchar('-'), x = -x;
  print(x), putchar(ch);
}
int n, h[Maxx], to[Maxx << 1], nx[Maxx << 1], lg[Maxx], prt[Maxx], f[Maxx][19];
int tot, d[Maxx], md[Maxx], sn[Maxx], tp[Maxx], td[Maxx], P[Maxx << 1];
const long long bs = 29;
long long hx[Maxx], hp[Maxx], mi[Maxx];
char S[Maxx];
inline void ckmax(int &x, const int y) { x = x > y ? x : y; }
inline int Min(const int x, const int y) { return x < y ? x : y; }
void Dfs1(int x, int fa) {
  md[x] = d[x] = d[prt[x] = f[x][0] = fa] + 1;
  hx[x] = (hx[fa] * bs + S[x] - 'a' + 1) % Mod;
  hp[x] = (hp[fa] + (S[x] - 'a' + 1) * mi[d[x] - 1]) % Mod;
  for (int i = 1; f[x][i - 1]; ++i) f[x][i] = f[f[x][i - 1]][i - 1];
  for (int i = h[x], y; i; i = nx[i])
    if ((y = to[i]) ^ fa) {
      Dfs1(y, x), ckmax(md[x], md[y]);
      if (md[sn[x]] < md[y]) sn[x] = y;
    }
}
void Dfs2(int x, int bo) {
  if (sn[x]) {
    for (int i = h[x], y; i; i = nx[i])
      if ((y = to[i]) ^ prt[x] && y ^ sn[x]) Dfs2(y, y);
    Dfs2(sn[x], bo);
  }
  if ((P[td[x] = ++tot] = x) == (tp[x] = bo)) {
    for (int i = md[x] - d[x]; i; --i) P[++tot] = x = prt[x];
  }
}
inline int FindK_fa(int x, int k) {
  if (!k) return x;
  x = f[x][lg[k]], k -= 1 << lg[k];
  return P[td[tp[x]] + k - d[x] + d[tp[x]]];
}
inline int lca(int x, int y) {
  if (d[x] < d[y]) x ^= y ^= x ^= y;
  for (int i = lg[d[x] - d[y]]; ~i; --i)
    if (d[f[x][i]] >= d[y]) x = f[x][i];
  if (x == y) return x;
  for (int i = lg[d[x]]; ~i; --i)
    if (f[x][i] ^ f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
struct node {
  long long v;
  int ln;
  inline node(long long a = 0, int b = 0) { v = a, ln = b; }
  inline bool operator==(const node &tp) {
    if (ln < tp.ln)
      return v * mi[tp.ln - ln] % Mod == tp.v;
    else
      return v == tp.v * mi[ln - tp.ln] % Mod;
  }
};
inline node Ask(int x, int y, int l, int ln) {
  static int p;
  static long long rx, ry;
  if ((p = d[x] - d[l] + 1) >= ln)
    return node((hx[x] - hx[FindK_fa(x, ln)] * mi[ln] % Mod + Mod) % Mod, ln);
  else {
    rx = (hx[x] - hx[prt[l]] * mi[p] % Mod + Mod) % Mod, ln -= p;
    ry = (hp[FindK_fa(y, d[y] - d[l] - ln)] - hp[l] + Mod) % Mod;
    if (d[l] >= p)
      rx = (rx * mi[d[l] - p] + ry) % Mod, ln += d[l];
    else
      rx = (rx + ry * mi[p - d[l]]) % Mod, ln += p;
    return node(rx, ln);
  }
}
int main() {
  n = read(), scanf("%s", S + 1), lg[0] = -1;
  for (int i = 1; i <= n; ++i) lg[i] = lg[i >> 1] + 1;
  for (int i = mi[0] = 1; i <= n; ++i) mi[i] = mi[i - 1] * bs % Mod;
  for (int i = 1, x, y; i < n; ++i) {
    nx[i << 1] = h[x = read()], to[h[x] = i << 1] = y = read();
    nx[i << 1 | 1] = h[y], to[h[y] = i << 1 | 1] = x;
  }
  Dfs1(1, 0), Dfs2(1, 1), n = read() + 1;
  int A, B, C, D, AB, CD, l, r, mid;
  while (--n) {
    A = read(), B = read(), C = read(), D = read();
    if (S[A] != S[C]) {
      puts("0");
      continue;
    }
    AB = lca(A, B), CD = lca(C, D);
    l = 1, r = Min(d[A] + d[B] - (d[AB] << 1), d[C] + d[D] - (d[CD] << 1)) + 1;
    while (l < r) {
      mid = l + r + 1 >> 1;
      if (Ask(A, B, AB, mid) == Ask(C, D, CD, mid))
        l = mid;
      else
        r = mid - 1;
    }
    printnum(l, '\n');
  }
  return 0;
}