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 __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;
template <typename T>
inline void read(T &x) {
  char ch, t = 0;
  x = 0;
  while (!isdigit(ch = (iS == iT
                            ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                               (iS == iT ? EOF : *iS++))
                            : *iS++)))
    t |= ch == '-';
  while (isdigit(ch))
    x = x * 10 + (ch ^ 48),
    ch = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                      (iS == iT ? EOF : *iS++))
                   : *iS++);
  x = t ? -x : x;
}
inline int read_int() {
  int x;
  return read(x), x;
}
inline long long read_ll() {
  long long x;
  return read(x), x;
}
template <typename T>
inline void chkmin(T &a, T b) {
  a = a < b ? a : b;
}
template <typename T>
inline void chkmax(T &a, T b) {
  a = a > b ? a : b;
}
const int mod = 104857601;
const int MAXN = 300010;
inline char get_alpha() {
  char c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                        (iS == iT ? EOF : *iS++))
                     : *iS++);
  while (!isalpha(c))
    c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                     (iS == iT ? EOF : *iS++))
                  : *iS++);
  return c;
}
int n;
vector<int> to[MAXN];
int up[MAXN];
int dn[MAXN];
int pw[MAXN * 2];
char s[MAXN];
int d[MAXN];
int Fa[MAXN][32][4];
int fa[MAXN][20];
int Log[MAXN];
inline void dfs(int x, int la) {
  up[x] = (37LL * up[la] + s[x]) % mod;
  dn[x] = (dn[la] + 1LL * s[x] * pw[d[la] + 1]) % mod;
  fa[x][0] = la, d[x] = d[la] + 1;
  for (int i = 1; i < 20; i++) fa[x][i] = fa[fa[x][i - 1]][i - 1];
  int La = la;
  for (int i = 0; i < 4; i++) {
    Fa[x][0][i] = x;
    Fa[x][1][i] = La;
    for (int j = 2; j < 32; j++) Fa[x][j][i] = La = Fa[La][1][i];
    La = Fa[La][1][i];
  }
  for (auto u : to[x]) {
    if (u == la) continue;
    dfs(u, x);
  }
}
inline int UP(int x, int k) {
  int t = 0;
  while (k) x = Fa[x][k & 31][t++], k >>= 5;
  return x;
}
inline int LCA(int x, int y) {
  if (d[x] < d[y]) swap(x, y);
  x = UP(x, d[x] - d[y]);
  if (x == y) return x;
  for (int i = 19; ~i; --i)
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
inline int calc(int u, int v, int a, int l) {
  if (d[u] - d[a] + 1 >= l) {
    int x = UP(u, l);
    return (1LL * up[u] * pw[n] + 1LL * (mod - up[x]) * pw[n + d[u] - d[x]]) %
           mod;
  } else {
    int x = UP(v, d[u] + d[v] - d[a] * 2 - l + 1);
    long long L = 1LL * up[u] * pw[n] +
                  1LL * (mod - up[fa[a][0]]) * pw[n + d[u] - d[a] + 1];
    long long R = 1LL * (dn[x] - dn[a] + mod) * pw[n + d[u] - d[a] * 2];
    return (L + R) % mod;
  }
}
int main() {
  n = read_int(), pw[0] = 1;
  for (int i = 1; i <= n * 2; i++) pw[i] = 37LL * pw[i - 1] % mod;
  for (int i = 2; i <= n; i++) Log[i] = Log[i >> 1] + 1;
  for (int i = 1; i <= n; i++) s[i] = get_alpha() - 'a';
  for (int i = 1; i < n; i++) {
    int u = read_int(), v = read_int();
    to[u].push_back(v);
    to[v].push_back(u);
  }
  d[0] = -1, dfs(1, 0);
  int q = read_int();
  while (q--) {
    int a = read_int(), b = read_int(), x = read_int(), y = read_int();
    int l1 = LCA(a, b), l2 = LCA(x, y);
    int L1 = d[a] + d[b] - d[l1] * 2 + 1;
    int L2 = d[x] + d[y] - d[l2] * 2 + 1;
    int l = 1, r = min(L1, L2);
    while (l <= r) {
      int mid = (l + r) >> 1;
      int Hash1 = calc(a, b, l1, mid);
      int Hash2 = calc(x, y, l2, mid);
      if (Hash1 == Hash2)
        l = mid + 1;
      else
        r = mid - 1;
    }
    printf("%d\n", l - 1);
  }
  return 0;
}