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;
namespace io {
const int __SIZE = (1 << 21) + 1;
char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1,
                                           __c, qu[55];
int __f, qr, _eof;
inline void flush() { fwrite(obuf, 1, oS - obuf, stdout), oS = obuf; }
inline void gc(char& x) {
  x = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                   (iS == iT ? EOF : *iS++))
                : *iS++);
}
inline void pc(char x) {
  *oS++ = x;
  if (oS == oT) flush();
}
inline void pstr(const char* s) {
  int __len = strlen(s);
  for (__f = 0; __f < __len; ++__f) pc(s[__f]);
}
inline void gstr(char* s) {
  for (__c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                         (iS == iT ? EOF : *iS++))
                       : *iS++);
       __c < 32 || __c > 126 || __c == ' ';)
    __c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                    : *iS++);
  for (; __c > 31 && __c < 127 && __c != ' ';
       ++s, __c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                            : *iS++))
    *s = __c;
  *s = 0;
}
template <class I>
inline bool gi(I& x) {
  _eof = 0;
  for (__f = 1,
      __c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                        (iS == iT ? EOF : *iS++))
                      : *iS++);
       (__c < '0' || __c > '9') && !_eof;
       __c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                         (iS == iT ? EOF : *iS++))
                       : *iS++)) {
    if (__c == '-') __f = -1;
    _eof |= __c == EOF;
  }
  for (x = 0; __c <= '9' && __c >= '0' && !_eof;
       __c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                         (iS == iT ? EOF : *iS++))
                       : *iS++))
    x = x * 10 + (__c & 15), _eof |= __c == EOF;
  x *= __f;
  return !_eof;
}
template <class I>
inline void print(I x) {
  if (!x) pc('0');
  if (x < 0) pc('-'), x = -x;
  while (x) qu[++qr] = x % 10 + '0', x /= 10;
  while (qr) pc(qu[qr--]);
}
struct Flusher_ {
  ~Flusher_() { flush(); }
} io_flusher_;
}  // namespace io
using io::gc;
using io::gi;
using io::gstr;
using io::pc;
using io::print;
using io::pstr;
using ll = long long;
using pii = pair<int, int>;
const int MOD = 1000000007;
const int bas = 108616, ibas = 358262137;
const int mxn = 3e5 + 5;
vector<int> elist[mxn];
int sz[mxn], hvc[mxn], hvp[mxn], o2n[mxn], dep[mxn], fa[mxn], cl = 1;
char s[mxn], nws[mxn];
int dfs1(int u, int f) {
  sz[u] = 1;
  for (int& v : elist[u])
    if (v != f) sz[u] += dfs1(v, u);
  return sz[u];
}
void dfs2(int u, int f, int hp) {
  o2n[u] = cl;
  nws[cl] = s[u];
  cl++;
  hvp[u] = hp;
  dep[u] = dep[f] + 1;
  fa[u] = f;
  pii bs = {0, 0};
  for (int& v : elist[u])
    if (v != f) bs = max(bs, {sz[v], v});
  if (!bs.second) return;
  dfs2(bs.second, u, hp);
  for (int& v : elist[u])
    if (v != f && v != bs.second) dfs2(v, u, v);
}
vector<pii> order(int u, int v) {
  vector<pii> fromU, fromV;
  while (hvp[u] != hvp[v]) {
    if (dep[hvp[u]] >= dep[hvp[v]]) {
      fromU.push_back({o2n[u], o2n[hvp[u]]});
      u = fa[hvp[u]];
    } else {
      fromV.push_back({o2n[hvp[v]], o2n[v]});
      v = fa[hvp[v]];
    }
  }
  fromU.push_back({o2n[u], o2n[v]});
  reverse(fromV.begin(), fromV.end());
  for (auto& k : fromV) fromU.push_back(k);
  return fromU;
}
int ex[mxn], iex[mxn];
pii app(pii a, pii o) {
  return {a.first + o.first, (a.second + 1ll * ex[a.first] * o.second) % MOD};
}
pii rem1(pii a, pii o) {
  return {a.first - o.first,
          1ll * (a.second + MOD - o.second) * iex[o.first] % MOD};
}
pii rem2(pii a, pii o) {
  return {a.first - o.first,
          (a.second + 1ll * ex[a.first - o.first] * (MOD - o.second)) % MOD};
}
pii fhs[mxn], rhs[mxn];
pii get(int l, int r) {
  if (l <= r)
    return rem1(fhs[r], fhs[l - 1]);
  else
    return rem2(rhs[l], rhs[r - 1]);
}
int len(int l, int r) { return max(l, r) - min(l, r) + 1; }
int tr(int l, int r, int k) { return (l <= r) ? (l + k - 1) : (l - k + 1); }
int t2(int l, int r, int k) { return (l <= r) ? (l + k) : (l - k); }
int work(int u1, int v1, int u2, int v2) {
  auto a = order(u1, v1), b = order(u2, v2);
  assert(a.size() && b.size());
  int ans = 0;
  pii ac = {-1, 0}, bc = {-1, 0};
  int adx = 0, bdx = 0;
  while (1) {
    if (ac.first == -1) {
      if (adx == a.size()) {
        break;
      }
      ac = a[adx++];
    }
    if (bc.first == -1) {
      if (bdx == b.size()) {
        break;
      }
      bc = b[bdx++];
    }
    int le = min(len(ac.first, ac.second), len(bc.first, bc.second));
    pii h1 = get(ac.first, tr(ac.first, ac.second, le)),
        h2 = get(bc.first, tr(bc.first, bc.second, le));
    if (h1 != h2) {
      int low = 1, high = le, dt = 0;
      while (low <= high) {
        int mid = (low + high) / 2;
        if (get(ac.first, tr(ac.first, ac.second, mid)) ==
            get(bc.first, tr(bc.first, bc.second, mid)))
          dt = mid, low = mid + 1;
        else
          high = mid - 1;
      }
      return ans + dt;
    } else
      ans += le;
    if (len(ac.first, ac.second) == le)
      ac.first = -1;
    else
      ac.first = t2(ac.first, ac.second, le);
    if (len(bc.first, bc.second) == le)
      bc.first = -1;
    else
      bc.first = t2(bc.first, bc.second, le);
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  gi(n);
  ex[0] = iex[0] = 1;
  for (int i = (1); i < ((n + 1) + 1); i++)
    ex[i] = 1ll * ex[i - 1] * bas % MOD, iex[i] = 1ll * iex[i - 1] * ibas % MOD;
  gstr(s + 1);
  for (int i = (0); i < (n - 1); i++) {
    int u, v;
    gi(u), gi(v);
    elist[u].push_back(v);
    elist[v].push_back(u);
  }
  dfs1(1, 0);
  dfs2(1, 0, 1);
  fhs[0] = {0, 0};
  for (int i = (1); i < ((n) + 1); i++) fhs[i] = app(fhs[i - 1], {1, nws[i]});
  rhs[0] = {0, 0};
  for (int i = (1); i < ((n) + 1); i++) rhs[i] = app({1, nws[i]}, rhs[i - 1]);
  int m;
  gi(m);
  while (m--) {
    int u1, v1, u2, v2;
    gi(u1), gi(v1), gi(u2), gi(v2);
    print(work(u1, v1, u2, v2));
    pc('\n');
  }
}