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;
struct edge {
  int s, t, nxt;
} e[600005];
int last[300005], e_cnt;
void ins(int a, int b) {
  e[e_cnt] = (edge){a, b, last[a]};
  last[a] = e_cnt++;
}
const int mod = 998244353;
char s[300005];
int dep[300005], fa[300005], Hsh[300005], iHsh[300005], p31[300005],
    ip31[300005], size[300005], mx[300005];
void dfs(int x) {
  size[x] = 1;
  for (int i = last[x]; i != -1; i = e[i].nxt)
    if (e[i].t != fa[x]) {
      fa[e[i].t] = x;
      dep[e[i].t] = dep[x] + 1;
      Hsh[e[i].t] =
          (Hsh[x] + 1ll * p31[dep[e[i].t]] * (s[e[i].t] - 'a' + 1)) % mod;
      iHsh[e[i].t] = (iHsh[x] * 31ll + s[e[i].t] - 'a' + 1) % mod;
      dfs(e[i].t);
      size[x] += size[e[i].t];
      mx[x] = (!mx[x] || size[e[i].t] > size[mx[x]] ? e[i].t : mx[x]);
    }
}
int top[300005], po[300005];
vector<int> mb[300005];
void dfs1(int x) {
  for (int i = last[x]; i != -1; i = e[i].nxt)
    if (e[i].t != fa[x]) {
      top[e[i].t] = (e[i].t == mx[x] ? top[x] : e[i].t);
      po[e[i].t] = mb[top[e[i].t]].size();
      mb[top[e[i].t]].push_back(e[i].t);
      dfs1(e[i].t);
    }
}
inline vector<pair<int, int> > get(int a, int b) {
  vector<pair<int, int> > res, t;
  while (top[a] != top[b]) {
    if (dep[top[a]] > dep[top[b]])
      res.push_back(make_pair(a, top[a])), a = fa[top[a]];
    else
      t.push_back(make_pair(top[b], b)), b = fa[top[b]];
  }
  res.push_back(make_pair(a, b));
  if (t.size())
    for (int i = t.size() - 1; i >= 0; i--) res.push_back(t[i]);
  return res;
}
inline int kth(int x, pair<int, int> Y, int k) {
  assert(po[x] + k * (po[Y.second] >= po[Y.first] ? 1 : -1) >= 0 &&
         po[x] + k * (po[Y.second] >= po[Y.first] ? 1 : -1) <
             mb[top[x]].size());
  return mb[top[x]][po[x] + k * (po[Y.second] >= po[Y.first] ? 1 : -1)];
}
inline int hsh(int a, int b) {
  if (dep[a] < dep[b])
    return 1ll * (Hsh[b] - Hsh[fa[a]] + mod) * ip31[dep[a]] % mod;
  return (iHsh[a] - 1ll * iHsh[fa[b]] * p31[dep[a] - dep[b] + 1] % mod + mod) %
         mod;
}
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", s + 1);
  memset(last, -1, sizeof(last));
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    ins(u, v);
    ins(v, u);
  }
  p31[0] = 1;
  for (int i = 1; i <= n; i++) p31[i] = 31ll * p31[i - 1] % mod;
  ip31[0] = 1;
  for (int i = 1; i <= n; i++) ip31[i] = 128805723ll * ip31[i - 1] % mod;
  Hsh[1] = iHsh[1] = s[1] - 'a' + 1;
  dfs(1);
  top[1] = 1;
  po[1] = 0;
  mb[1].push_back(1);
  dfs1(1);
  int m;
  scanf("%d", &m);
  while (m--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    vector<pair<int, int> > X = get(a, b), Y = get(c, d);
    int ans = 0;
    for (int i = 0, j = 0;;) {
      int l = min(abs(po[X[i].second] - po[a]), abs(po[Y[j].second] - po[c]));
      int na = kth(a, X[i], l), nc = kth(c, Y[j], l);
      if (hsh(a, na) != hsh(c, nc)) {
        int L = 0, R = l;
        while (L < R) {
          int mid = L + ((R - L) >> 1);
          if (hsh(a, kth(a, X[i], mid)) == hsh(c, kth(c, Y[j], mid)))
            L = mid + 1;
          else
            R = mid;
        }
        ans += L;
        break;
      }
      ans += l + 1;
      if (na == X[i].second) {
        i++;
        if (i >= X.size()) break;
        a = X[i].first;
      } else
        a = kth(a, X[i], l + 1);
      if (nc == Y[j].second) {
        j++;
        if (j >= Y.size()) break;
        c = Y[j].first;
      } else
        c = kth(c, Y[j], l + 1);
    }
    printf("%d\n", ans);
  }
}