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;
int inf;
const double eps = 1e-8;
const double pi = acos(-1.0);
template <class T, class T2>
int chkmin(T &a, T2 b) {
  return a > b ? a = b, 1 : 0;
}
template <class T, class T2>
int chkmax(T &a, T2 b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
T sqr(T a) {
  return a * a;
}
template <class T, class T2>
T mmin(T a, T2 b) {
  return a < b ? a : b;
}
template <class T, class T2>
T mmax(T a, T2 b) {
  return a > b ? a : b;
}
template <class T>
T aabs(T a) {
  return a < 0 ? -a : a;
}
template <class T>
int dcmp(T a, T b) {
  return a > b;
}
template <int *a>
int cmp_a(int first, int second) {
  return a[first] < a[second];
}
template <class T>
bool sort2(T &a, T &b) {
  return a > b ? swap(a, b), 1 : 0;
}
struct __INIT__ {
  __INIT__() {
    fill((unsigned char *)&inf, (unsigned char *)&inf + sizeof(inf), 0x3f);
  }
} __INIT___;
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;
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char first) {
  *oS++ = first;
  if (oS == oT) flush();
}
template <typename A>
inline bool read(A &first) {
  for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                            : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-')
      f = -1;
    else if (c == EOF)
      return 0;
  for (first = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    first = first * 10 + (c & 15);
  first *= f;
  return 1;
}
inline bool read(char &first) {
  while ((first = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                               (iS == iT ? EOF : *iS++))
                            : *iS++)) == ' ' ||
         first == '\n' || first == '\r')
    ;
  return first != EOF;
}
inline bool read(char *first) {
  while ((*first = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                                (iS == iT ? EOF : *iS++))
                             : *iS++)) == '\n' ||
         *first == ' ' || *first == '\r')
    ;
  if (*first == EOF) return 0;
  while (!(*first == '\n' || *first == ' ' || *first == '\r' || *first == EOF))
    *(++first) = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                           : *iS++);
  *first = 0;
  return 1;
}
template <typename A, typename... B>
inline bool read(A &first, B &...second) {
  return read(first) && read(second...);
}
template <typename A>
inline bool write(A first) {
  if (!first) putc('0');
  if (first < 0) putc('-'), first = -first;
  while (first) qu[++qr] = first % 10 + '0', first /= 10;
  while (qr) putc(qu[qr--]);
  return 0;
}
inline bool write(char first) {
  putc(first);
  return 0;
}
inline bool write(const char *first) {
  while (*first) {
    putc(*first);
    ++first;
  }
  return 0;
}
inline bool write(char *first) {
  while (*first) {
    putc(*first);
    ++first;
  }
  return 0;
}
template <typename A, typename... B>
inline bool write(A first, B... second) {
  return write(first) || write(second...);
}
struct Flusher_ {
  ~Flusher_() { flush(); }
} io_flusher_;
}  // namespace io
using io ::putc;
using io ::read;
using io ::write;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
int isp(int first) {
  if (first == 1) return 0;
  for (int i = 2; i * i <= first; ++i)
    if (!(first % i)) return 0;
  return 1;
}
int getp(int l, int r) {
  int w;
  while (!isp(w = rnd() % (r - l) + l))
    ;
  return w;
}
const int c = 3;
long long h[c][600005], pw[c][600005];
long long xp[c], xq[c];
int n, u, v;
vector<int> to[300005];
char s[300005], s1[600005];
int siz[300005], mxs[300005], hvy[300005];
int dfn[300005], xdfn[300005], t;
int top[300005], tdp[300005], fa[300005];
void initHash() {
  for (int i = 0; i < c; ++i) {
    long long &p = xp[i], &q = xq[i];
    p = getp(900000000, 1000000000);
    q = getp(1, 1000);
    pw[i][0] = 1;
    for (int j = 1; j <= t; ++j) {
      pw[i][j] = pw[i][j - 1] * q % p;
      h[i][j] = (h[i][j - 1] * q + s1[j] - 'a') % p;
    }
  }
}
int match(int first, int second, int t) {
  for (int i = 0; i < c; ++i) {
    if (((h[i][first + t] - h[i][second + t]) +
         (h[i][second] - h[i][first]) * pw[i][t]) %
        xp[i])
      return 0;
  }
  return 1;
}
void dfs(int first, int f) {
  siz[first] = 1;
  for (auto i : to[first])
    if (i != f) {
      dfs(i, first);
      siz[first] += siz[i];
      if (chkmax(mxs[first], siz[i])) hvy[first] = i;
    }
}
void dfs2(int first, int f) {
  fa[first] = f;
  if (!top[first]) {
    top[first] = first;
    tdp[first] = tdp[f] + 1;
  }
  dfn[first] = ++t;
  xdfn[first] = n + n - t + 1;
  s1[dfn[first]] = s1[xdfn[first]] = s[first];
  if (hvy[first]) {
    tdp[hvy[first]] = tdp[first];
    top[hvy[first]] = top[first];
    dfs2(hvy[first], first);
    for (auto i : to[first])
      if (i != f && i != hvy[first]) dfs2(i, first);
  }
}
int l1[600005], r1[600005], t1;
int l2[600005], r2[600005], t2;
int xl[600005], xr[600005], xt;
void make(int first, int second, int *l, int *r, int &t) {
  xt = t = 0;
  while (top[first] != top[second]) {
    if (tdp[first] < tdp[second]) {
      l[++t] = dfn[top[second]] - 1;
      r[t] = dfn[second];
      second = fa[top[second]];
    } else {
      xl[++xt] = xdfn[first] - 1;
      xr[xt] = xdfn[top[first]];
      first = fa[top[first]];
    }
  }
  if (dfn[first] <= dfn[second]) {
    l[++t] = dfn[first] - 1;
    r[t] = dfn[second];
  } else {
    l[++t] = xdfn[first] - 1;
    r[t] = xdfn[second];
  }
  while (xt) {
    l[++t] = xl[xt];
    r[t] = xr[xt];
    --xt;
  }
}
int query() {
  int ans = 0;
  while (t1 && t2) {
    int &first = l1[t1], &second = l2[t2];
    int s = mmin(r1[t1] - l1[t1], r2[t2] - l2[t2]);
    if (match(first, second, s)) {
      ans += s;
      first += s;
      second += s;
    } else {
      int l = 1, r = s;
      while (l <= r) {
        int mid = (l + r) >> 1;
        if (match(first, second, mid))
          l = mid + 1;
        else
          r = mid - 1;
      }
      ans += l - 1;
      break;
    }
    if (first == r1[t1]) --t1;
    if (second == r2[t2]) --t2;
  }
  return ans;
}
signed main() {
  read(n);
  read(s + 1);
  for (int i = 1; i < n; ++i) {
    read(u, v);
    to[u].emplace_back(v);
    to[v].emplace_back(u);
  }
  dfs(1, 0);
  dfs2(1, 0);
  t <<= 1;
  initHash();
  int q;
  read(q);
  for (; q; --q) {
    int a, b, c, d;
    read(a, b, c, d);
    make(a, b, l1, r1, t1);
    make(c, d, l2, r2, t2);
    write(query(), '\n');
  }
  return 0;
}