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>
int gi() {
  static int ch, x;
  while ((ch = getchar()) < 48) {
  }
  x = ch ^ 48;
  while ((ch = getchar()) >= 48) x = (((x << 2) + x) << 1) + (ch ^ 48);
  return x;
}
char ga() {
  static int ch;
  while ((ch = getchar()) <= 96) {
  }
  return ch;
}
struct edge {
  int next, to;
} e[300010 << 1];
constexpr int BS = 521, P = 1073741789;
template <const int P = ::P>
constexpr int fix(const int &x) {
  return x + ((x >> 31) & P);
}
struct hash_t {
  int val;
  constexpr hash_t() : val(){};
  constexpr hash_t(const int &val) : val(val){};
  friend constexpr hash_t operator+(const hash_t &x, const hash_t &y) {
    return hash_t(fix(x.val + y.val - P));
  }
  friend constexpr hash_t operator-(const hash_t &x, const hash_t &y) {
    return hash_t(fix(x.val - y.val));
  }
  friend constexpr hash_t operator*(const hash_t &x, const hash_t &y) {
    return hash_t(1ll * x.val * y.val % P);
  }
  friend constexpr bool operator!=(const hash_t &x, const hash_t &y) {
    return x.val != y.val;
  }
  constexpr hash_t append(const char &);
};
typedef int arr[300010];
typedef hash_t hsarr[300010];
constexpr hash_t HSBASE(BS);
constexpr hash_t hash_t::append(const char &c) {
  return *this * HSBASE + hash_t(c);
}
int ei, cnt;
char c[300010];
arr head, siz, hson, top, dep, fa, dfn, seg;
hsarr pre, suf, bs;
std::vector<std::pair<int, int>>::iterator it, jt;
void dfs1(const int &f) {
  dep[f] = dep[fa[f]] + 1;
  siz[f] = 1;
  for (int i = head[f]; i; i = e[i].next) {
    const int t = e[i].to;
    if (!siz[t]) {
      fa[t] = f;
      dfs1(t);
      if (siz[t] > siz[hson[f]]) hson[f] = t;
      siz[f] += siz[t];
    }
  }
}
void dfs2(const int &f) {
  dfn[f] = ++cnt;
  seg[cnt] = f;
  if (hson[f]) {
    top[hson[f]] = top[f];
    dfs2(hson[f]);
    for (int i = head[f]; i; i = e[i].next) {
      const int t = e[i].to;
      if (t != fa[f] && t != hson[f]) {
        top[t] = t;
        dfs2(t);
      }
    }
  }
}
void getpath(int x, int y, std::vector<std::pair<int, int>> &ans) {
  static std::vector<std::pair<int, int>> tmp;
  ans.clear();
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) {
      tmp.push_back(std::make_pair(top[y], y));
      y = fa[top[y]];
    } else {
      ans.push_back(std::make_pair(x, top[x]));
      x = fa[top[x]];
    }
  }
  ans.push_back(std::make_pair(x, y));
  while (!tmp.empty()) {
    ans.push_back(tmp.back());
    tmp.pop_back();
  }
}
inline hash_t hash(const bool &r, const int &p, const int &l) {
  return r ? (suf[p - l + 1] - suf[p + 1] * bs[l])
           : (pre[p + l - 1] - pre[p - 1] * bs[l]);
}
int main() {
  bs[0] = hash_t(1);
  const int n = gi();
  for (int i = 1; i <= n; ++i) {
    c[i] = ga();
    bs[i] = bs[i - 1] * HSBASE;
  }
  for (int i = n; --i;) {
    const int x = gi(), y = gi();
    (e[++ei].next = head[x], e[ei].to = (y), head[x] = ei);
    (e[++ei].next = head[y], e[ei].to = (x), head[y] = ei);
  }
  dfs1(1);
  top[1] = 1;
  dfs2(1);
  for (int i = 1; i <= n; ++i) pre[i] = pre[i - 1].append(c[seg[i]]);
  for (int i = n; i >= 1; --i) suf[i] = suf[i + 1].append(c[seg[i]]);
  for (int m = gi(); m--;) {
    int a = gi(), b = gi(), c = gi(), d = gi(), ans = 0;
    static std::vector<std::pair<int, int>> p1, p2;
    getpath(a, b, p1);
    getpath(c, d, p2);
    it = p1.begin();
    jt = p2.begin();
    while (it != p1.end() && jt != p2.end()) {
      const int f1 = dfn[it->first], t1 = dfn[it->second];
      const int f2 = dfn[jt->first], t2 = dfn[jt->second];
      const bool r1 = f1 > t1, r2 = f2 > t2;
      const int l1 = (r1 ? (f1 - t1) : (t1 - f1)) + 1;
      const int l2 = (r2 ? (f2 - t2) : (t2 - f2)) + 1;
      const int len = std::min(l1, l2);
      if (hash(r1, f1, len) != hash(r2, f2, len)) {
        int l = 0, r = len;
        while (l + 1 < r) {
          const int mid = (l + r) >> 1;
          if (hash(r1, f1, mid) != hash(r2, f2, mid)) {
            r = mid;
          } else {
            l = mid;
          }
        }
        ans += l;
        break;
      }
      if (len == l1) {
        ++it;
      } else {
        it->first = seg[f1 + (r1 ? -len : len)];
      }
      if (len == l2) {
        ++jt;
      } else {
        jt->first = seg[f2 + (r2 ? -len : len)];
      }
      ans += len;
    }
    printf("%d\n", ans);
  }
  return 0;
}