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(3, "Ofast", "inline")
#pragma GCC target("avx")
using namespace std;
template <class t>
inline t read(t &x) {
  char c = getchar();
  bool f = 0;
  x = 0;
  while (!isdigit(c)) f |= c == '-', c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f) x = -x;
  return x;
}
template <class t>
inline void write(t x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
const int N = 6e5 + 5;
int mod, id[N], dfn, mp[N], dlca[N], flca[N][23], pw[N], inv[N], upha[N],
    downha[N], s[N], d[N], dep[N], f[N][23], top[N], lg[N], n, m, rt;
char ch[N];
vector<int> up[N], down[N], g[N];
bool isprime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return 0;
  return 1;
}
int fpow(int x, int y) {
  int res = 1;
  for (; y; y >>= 1, x = 1ll * x * x % mod)
    if (y & 1) res = 1ll * res * x % mod;
  return res;
}
void dfs1(int x) {
  id[x] = ++dfn;
  mp[dfn] = x;
  dlca[dfn] = dep[x] = d[x] = d[f[x][0]] + 1;
  upha[x] = (1ll * upha[f[x][0]] + 1ll * pw[d[x] - 1] * ch[x]) % mod;
  downha[x] = (1ll * downha[f[x][0]] * 233 + ch[x]) % mod;
  for (int y : g[x])
    if (y ^ f[x][0]) {
      f[y][0] = x;
      for (int j = 0; f[y][j]; j++) f[y][j + 1] = f[f[y][j]][j];
      dfs1(y);
      mp[++dfn] = x;
      dlca[dfn] = d[x];
      if (dep[y] > dep[x]) dep[x] = dep[y], s[x] = y;
    }
}
void dfs2(int x, int TOP) {
  top[x] = TOP;
  if (x == TOP) {
    for (int i = 0, pt = x; i <= dep[x] - d[x]; i++)
      up[x].push_back(pt), pt = f[pt][0];
    for (int i = 0, pt = x; i <= dep[x] - d[x]; i++)
      down[x].push_back(pt), pt = s[pt];
  }
  if (s[x]) dfs2(s[x], TOP);
  for (int y : g[x])
    if (y ^ f[x][0])
      if (y ^ s[x]) dfs2(y, y);
}
int kthfa(int x, int k) {
  if (!k) return x;
  if (k >= d[x]) return 0;
  x = f[x][lg[k]];
  k -= 1 << lg[k];
  k -= d[x] - d[top[x]];
  x = top[x];
  if (k >= 0)
    return up[x][k];
  else
    return down[x][-k];
}
int dmin(int x, int y) { return dlca[x] < dlca[y] ? x : y; }
void init(int n) {
  for (int i = 1; i <= n; i++) flca[i][0] = i;
  for (int j = 1; j <= lg[n]; j++)
    for (int i = 1; i + (1 << j) - 1 <= n; i++)
      flca[i][j] = dmin(flca[i][j - 1], flca[i + (1 << j - 1)][j - 1]);
}
int lca(int x, int y) {
  int l = id[x], r = id[y];
  if (l > r) swap(l, r);
  int k = lg[r - l + 1];
  return mp[dmin(flca[l][k], flca[r - (1 << k) + 1][k])];
}
int len(int x, int y) {
  int LCA = lca(x, y);
  return d[x] + d[y] - 2 * d[LCA];
}
int getupha(int x, int len) {
  int y = kthfa(x, len);
  return 1ll * (upha[x] - upha[y] + mod) % mod * inv[d[x] - len] % mod;
}
int getdownha(int x, int len) {
  int y = kthfa(x, len);
  return (downha[x] - 1ll * downha[y] * pw[len] % mod + mod) % mod;
}
int getha(int x, int y, int len) {
  int LCA = lca(x, y);
  if (LCA == x) {
    return getdownha(kthfa(y, d[y] - d[LCA] - len + 1), len);
  }
  int ha1 = getupha(x, min(len, d[x] - d[LCA]));
  if (len <= d[x] - d[LCA]) return ha1;
  len -= d[x] - d[LCA];
  int ha2 = getdownha(kthfa(y, d[y] - d[LCA] - len + 1), len);
  return (1ll * ha1 * pw[len] + ha2) % mod;
}
signed main() {
  srand(time(NULL));
  for (mod = 1e9 + 7 + rand(); !isprime(mod); mod++)
    ;
  read(n);
  pw[0] = inv[0] = 1;
  inv[1] = fpow(233, mod - 2);
  for (int i = 2; i <= n; i++) inv[i] = 1ll * inv[i - 1] * inv[1] % mod;
  for (int i = 1; i <= n; i++) pw[i] = 1ll * pw[i - 1] * 233 % mod;
  scanf("%s", ch + 1);
  for (int i = 1, x, y; i < n; i++) {
    read(x);
    read(y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 2; i <= n * 2; i++) lg[i] = lg[i >> 1] + 1;
  rt = rand() % n + 1;
  dfs1(rt);
  dfs2(rt, rt);
  init(dfn);
  read(m);
  while (m--) {
    int a, b, c, d;
    read(a);
    read(b);
    read(c);
    read(d);
    int l = 1, r = min(len(a, b), len(c, d)) + 1, cur = 0;
    while (l <= r) {
      int mid = l + r >> 1;
      if (getha(a, b, mid) == getha(c, d, mid))
        cur = mid, l = mid + 1;
      else
        r = mid - 1;
    }
    write(cur);
    puts("");
  }
}