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;
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
const char lf = '\n';
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0, b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return a;
}
inline int ts(char *s) {
  int a = 0, c = fetch();
  while (c <= 32 && c != EOF) c = fetch();
  while (c > 32 && c != EOF) s[a++] = c, c = fetch();
  s[a] = 0;
  return a;
}
}  // namespace ae86
using ae86::ts;
using ae86::ty;
const int _ = 300007, __ = _ << 1, lglg = 20;
int lg2[__] = {0};
struct riki {
  static const int _s = __;
  int n;
  char s[_s];
  int sa[_s], rk[_s], buc[_s], x[_s], y[_s];
  void makesa(int m) {
    for (int i = 0; i <= m; i++) buc[i] = 0;
    for (int i = 1; i <= n; i++) buc[x[y[i]]]++;
    for (int i = 1; i <= m; i++) buc[i] += buc[i - 1];
    for (int i = n; i >= 1; i--) sa[buc[x[y[i]]]--] = y[i];
  }
  int hig[_s], phig[lglg + 1][_s];
  void make(int n_, char s_[], int m = 255) {
    n = n_;
    for (int i = 1; i <= n; i++) s[i] = s_[i];
    for (int i = 1; i <= n; i++) x[i] = s[i] - 'a', y[i] = i;
    makesa(m);
    for (int k = 1; k <= n; k <<= 1) {
      int p = 0;
      for (int i = n - k + 1; i <= n; i++) y[++p] = i;
      for (int i = 1; i <= n; i++)
        if (sa[i] > k) y[++p] = sa[i] - k;
      makesa(m), swap(x, y), x[sa[1]] = p = 1;
      for (int i = 2; i <= n; i++)
        x[sa[i]] =
            (y[sa[i]] == y[sa[i - 1]] && y[sa[i] + k] == y[sa[i - 1] + k])
                ? p
                : ++p;
      if (p >= n) break;
      m = p;
    }
    for (int i = 1; i <= n; i++) rk[sa[i]] = i;
    for (int i = 1, a = 0; i <= n; i++) {
      if (a) a--;
      while (s[i + a] == s[sa[rk[i] - 1] + a]) a++;
      hig[rk[i]] = a;
    }
    for (int i = 1; i <= n; i++) phig[0][i] = hig[i];
    for (int i = 1; i <= lglg; i++)
      for (int j = 1; j + (1 << (i)) - 1 <= n; j++)
        phig[i][j] = min(phig[i - 1][j], phig[i - 1][j + (1 << (i - 1))]);
  }
  int lcp(int a, int b) {
    if (a == b) return n - max(a, b) + 1;
    a = rk[a], b = rk[b];
    if (a > b) swap(a, b);
    a++;
    int k = lg2[b - a + 1];
    return min(phig[k][a], phig[k][b - (1 << (k)) + 1]);
  }
} sa;
int to[__], ne[__], he[_] = {0}, ecnt = 1;
inline void adde(int a, int b) {
  to[++ecnt] = b, ne[ecnt] = he[a], he[a] = ecnt;
}
inline void addde(int a, int b) { adde(a, b), adde(b, a); }
int n;
char str[_];
int fa[_] = {0}, dep[_] = {0}, sz[_] = {0}, mxch[_] = {0};
void dfs(int x, int ff) {
  fa[x] = ff, dep[x] = dep[ff] + 1, sz[x] = 1;
  for (int i = he[x]; i; i = ne[i]) {
    int b = to[i];
    if (b == ff) continue;
    dfs(b, x), sz[x] += sz[b];
    if (sz[mxch[x]] < sz[b]) mxch[x] = b;
  }
}
int dfn[_] = {0}, rdfn[_] = {0}, dcnt = 0, top[_] = {0};
char ps[__];
int lps = 0;
void dfs2(int x, int tp) {
  dfn[x] = ++dcnt, rdfn[dcnt] = x, top[x] = tp, ps[++lps] = str[x];
  if (mxch[x]) dfs2(mxch[x], tp);
  for (int i = he[x]; i; i = ne[i]) {
    int b = to[i];
    if (b == fa[x] || b == mxch[x]) continue;
    dfs2(b, b);
  }
}
int nn;
vector<pair<int, int>> fuck(int a, int b) {
  vector<pair<int, int>> aa, bb;
  while (top[a] != top[b]) {
    if (dep[top[a]] > dep[top[b]])
      aa.emplace_back(nn + 1 - dfn[a], dfn[a] - dfn[top[a]] + 1),
          a = fa[top[a]];
    else
      bb.emplace_back(dfn[top[b]], dfn[b] - dfn[top[b]] + 1), b = fa[top[b]];
  }
  if (dep[a] > dep[b])
    aa.emplace_back(nn + 1 - dfn[a], dfn[a] - dfn[b] + 1);
  else
    bb.emplace_back(dfn[a], dfn[b] - dfn[a] + 1);
  reverse(bb.begin(), bb.end()), aa.insert(aa.end(), bb.begin(), bb.end());
  return aa;
}
int main() {
  ios::sync_with_stdio(0), cout.tie(nullptr);
  lg2[0] = -1, lg2[1] = 0;
  for (int i = 2; i < __; i++) lg2[i] = lg2[i >> 1] + 1;
  n = ty(), nn = n + n, ts(str + 1);
  for (int i = 1, a, b; i < n; i++) a = ty(), b = ty(), addde(a, b);
  dfs(1, 0), dfs2(1, 1);
  for (int i = 1; i <= n; i++) ps[n + i] = ps[n + 1 - i];
  sa.make(nn, ps);
  for (int qq = 1, qn = ty(); qq <= qn; qq++) {
    int a_ = ty(), b_ = ty(), c_ = ty(), d_ = ty();
    vector<pair<int, int>> a = fuck(a_, b_), b = fuck(c_, d_);
    int ans = 0;
    for (int i = 0, j = 0;
         i < ((int)((a).size())) && j < ((int)((b).size()));) {
      int c =
          min(sa.lcp(a[i].first, b[j].first), min(a[i].second, b[j].second));
      ans += c;
      if (c < min(a[i].second, b[j].second)) break;
      if (c == a[i].second)
        i++;
      else
        a[i].first += c, a[i].second -= c;
      if (c == b[j].second)
        j++;
      else
        b[j].first += c, b[j].second -= c;
    }
    cout << ans << lf;
  }
  return 0;
}