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("O3")
#pragma GCC optimize("Ofast,no-stack-protector")
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\n";
  err(++it, args...);
}
function<void(void)> ____ = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
};
template <typename T>
vector<T> &operator<<(vector<T> &__container, T x) {
  __container.push_back(x);
  return __container;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> &__container) {
  for (T _ : __container) out << _ << ' ';
  return out;
}
void sci() {}
template <typename... Args>
void sci(int &x, Args &...args) {
  scanf("%d", &x);
  sci(args...);
}
void scl() {}
template <typename... Args>
void scl(long long int &x, Args &...args) {
  scanf("%lld", &x);
  scl(args...);
}
const int MAXN = 6e5 + 7;
const pair<int, int> MOD = {1004535809, 998244353};
const pair<int, int> BASE = {233, 137};
int ksm(int a, int b, int p) {
  int ret = 1;
  while (b) {
    if (b & 1) ret = 1ll * ret * a % p;
    b >>= 1;
    a = 1ll * a * a % p;
  }
  return ret;
}
int inv(int x, int p) { return ksm(x, p - 2, p); }
pair<int, int> operator+(pair<int, int> A, pair<int, int> B) {
  A.first += B.first;
  A.second += B.second;
  if (A.first >= MOD.first) A.first -= MOD.first;
  if (A.second >= MOD.second) A.second -= MOD.second;
  return A;
}
pair<int, int> operator-(pair<int, int> A, pair<int, int> B) {
  A.first -= B.first;
  A.second -= B.second;
  if (A.first < 0) A.first += MOD.first;
  if (A.second < 0) A.second += MOD.second;
  return A;
}
pair<int, int> operator*(pair<int, int> A, pair<int, int> B) {
  return make_pair(1ll * A.first * B.first % MOD.first,
                   1ll * A.second * B.second % MOD.second);
}
pair<int, int> pw[MAXN], rpw[MAXN];
int n, m, fst[MAXN], rdfn[MAXN], idx, dep[MAXN], par[MAXN][20], son[MAXN],
    maxd[MAXN], top[MAXN], highbit[MAXN], ST[MAXN][20], lg2[MAXN];
vector<int> G[MAXN], nodeup[MAXN], nodedown[MAXN];
pair<int, int> h[MAXN], rh[MAXN];
char s[MAXN];
void dfs(int u, int fa) {
  dep[u] = dep[par[u][0] = fa] + 1;
  maxd[u] = dep[u];
  for (int i = 1; par[u][i - 1]; i++) par[u][i] = par[par[u][i - 1]][i - 1];
  rdfn[++idx] = u;
  fst[u] = idx;
  h[u] = h[fa] * BASE + make_pair(s[u], s[u]);
  rh[u] = rh[fa] + make_pair(s[u], s[u]) * pw[dep[u] - 1];
  for (int &v : G[u]) {
    if (v == fa) continue;
    dfs(v, u);
    if (maxd[v] > maxd[u]) maxd[u] = maxd[v], son[u] = v;
    rdfn[++idx] = u;
  }
}
void dfs1(int u, int tp) {
  top[u] = tp;
  if (u == tp)
    for (int i = 0, x = u, y = u; i <= maxd[u] - dep[u];
         i++, x = par[x][0], y = son[y])
      nodeup[u] << x, nodedown[u] << y;
  if (son[u]) dfs1(son[u], tp);
  for (int &v : G[u])
    if (v != par[u][0] and v != son[u]) dfs1(v, v);
}
inline int LCA(int u, int v) {
  int l = fst[u], r = fst[v];
  if (l > r) l ^= r ^= l ^= r;
  int d = lg2[r - l + 1];
  if (dep[ST[l][d]] < dep[ST[r - (1 << d) + 1][d]])
    return ST[l][d];
  else
    return ST[r - (1 << d) + 1][d];
}
inline int kth_anc(int x, int k) {
  if (!k) return x;
  x = par[x][highbit[k]];
  k -= (1 << highbit[k]);
  k -= dep[x] - dep[top[x]];
  x = top[x];
  return k < 0 ? nodedown[x][-k] : nodeup[x][k];
}
void preprocess() {
  lg2[0] = -1;
  for (int i = 1; i < MAXN; i++) lg2[i] = lg2[i >> 1] + 1;
  for (int i = 2; i < MAXN; i++) highbit[i] = highbit[i >> 1] + 1;
  pw[0].first = pw[0].second = rpw[0].first = rpw[0].second = 1;
  pair<int, int> INVBASE =
      make_pair(inv(BASE.first, MOD.first), inv(BASE.second, MOD.second));
  for (int i = 1; i < MAXN; i++) pw[i] = pw[i - 1] * BASE;
  for (int i = 1; i < MAXN; i++) rpw[i] = rpw[i - 1] * INVBASE;
}
inline pair<int, int> calhash(int u, int k) {
  int anc = kth_anc(u, k);
  return h[u] - h[par[anc][0]] * pw[dep[u] - dep[anc] + 1];
}
inline pair<int, int> calrhash(int u, int k) {
  int anc = kth_anc(u, k);
  return (rh[u] - rh[par[anc][0]]) * rpw[dep[anc] - 1];
}
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return f * x;
}
void test() {
  int a = read(), b = read(), c = read(), d = read();
  int lca_ab = LCA(a, b), lca_cd = LCA(c, d);
  int d_ab = dep[a] + dep[b] - 2 * dep[lca_ab],
      d_cd = dep[c] + dep[d] - 2 * dep[lca_cd];
  int l = 1, r = min(d_ab, d_cd) + 1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    int dis = mid - 1;
    pair<int, int> hash_ab, hash_cd;
    if (dis <= dep[a] - dep[lca_ab])
      hash_ab = calrhash(a, dis);
    else
      hash_ab =
          calrhash(a, dep[a] - dep[lca_ab]) * pw[dis - dep[a] + dep[lca_ab]] +
          calhash(kth_anc(b, d_ab - dis),
                  dep[kth_anc(b, d_ab - dis)] - dep[lca_ab] - 1);
    if (dis <= dep[c] - dep[lca_cd])
      hash_cd = calrhash(c, dis);
    else
      hash_cd =
          calrhash(c, dep[c] - dep[lca_cd]) * pw[dis - dep[c] + dep[lca_cd]] +
          calhash(kth_anc(d, d_cd - dis),
                  dep[kth_anc(d, d_cd - dis)] - dep[lca_cd] - 1);
    if (hash_ab == hash_cd)
      l = mid + 1;
    else
      r = mid - 1;
  }
  printf("%d\n", r);
}
void solve() {
  preprocess();
  n = read();
  scanf("%s", s + 1);
  for (int i = 1; i < n; i++) {
    int u, v;
    sci(u, v);
    G[u] << v;
    G[v] << u;
  }
  dfs(1, 0);
  dfs1(1, 1);
  for (int i = 1; i <= idx; i++) ST[i][0] = rdfn[i];
  for (int j = 1; (1 << j) <= idx; j++)
    for (int i = 1; i + (1 << j) - 1 <= idx; i++) {
      if (dep[ST[i][j - 1]] < dep[ST[i + (1 << (j - 1))][j - 1]])
        ST[i][j] = ST[i][j - 1];
      else
        ST[i][j] = ST[i + (1 << (j - 1))][j - 1];
    }
  for (m = read(); m--; test())
    ;
}
int main() {
  solve();
  return 0;
}