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 gi() {
  char ch = '!';
  int res = 0, f = 0;
  while (ch < '0' || ch > '9') {
    ch = getchar();
    if (ch == '-') f = 1;
  }
  while (ch >= '0' && ch <= '9') res = res * 10 + ch - '0', ch = getchar();
  return f ? -res : res;
}
const int N = 3e5 + 100, bs = 19260817, P1 = 1e9 + 7, P2 = 1e9 + 9;
int upd(int x, int y) { return x >= y ? x - y : x; }
pair<int, int> operator+(pair<int, int> A, pair<int, int> B) {
  return make_pair(upd(A.first + B.first, P1), upd(A.second + B.second, P2));
}
pair<int, int> operator-(pair<int, int> A, pair<int, int> B) {
  return make_pair(upd(A.first - B.first + P1, P1),
                   upd(A.second - B.second + P2, P2));
}
pair<int, int> operator*(int x, pair<int, int> A) {
  return make_pair(1ll * x * A.first % P1, 1ll * x * A.second % P2);
}
pair<int, int> operator+(pair<int, int> A, int x) {
  return make_pair(upd(A.first + x, P1), upd(A.second + x, P2));
}
pair<int, int> operator*(pair<int, int> A, pair<int, int> B) {
  return make_pair(1ll * A.first * B.first % P1,
                   1ll * A.second * B.second % P2);
}
int n, top[N], son[N], dep[N], fa[N], dfn[N], sz[N], ind[N], Time;
pair<int, int> pw[N], h1[N], h2[N];
char ch[N];
int head[N], ce;
struct edge {
  int to, nxt;
} e[N << 1];
void lnk(int a, int b) { e[++ce] = (edge){b, head[a]}, head[a] = ce; }
struct node {
  int l, r, len, o;
};
vector<node> sp0, sp1, vec;
void dfs1(int u, int lst) {
  fa[u] = lst, dep[u] = dep[lst] + 1, sz[u] = 1;
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == lst) continue;
    dfs1(v, u), sz[u] += sz[v];
    son[u] = sz[son[u]] > sz[v] ? son[u] : v;
  }
}
void dfs2(int u, int lst) {
  top[u] = son[fa[u]] == u ? top[fa[u]] : u, ind[dfn[u] = ++Time] = u;
  if (son[u]) dfs2(son[u], u);
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == lst || v == son[u]) continue;
    dfs2(v, u);
  }
}
pair<int, int> Hash(node p, int l, int r) {
  pair<int, int> ret;
  if (!p.o)
    ret = h1[dfn[p.l] - l + 1] - pw[r - l + 1] * h1[dfn[p.l] - r];
  else
    ret = h2[dfn[p.l] + l - 1] - pw[r - l + 1] * h2[dfn[p.l] + r];
  return ret;
}
void get_string(int a, int b, vector<node> &pot) {
  int lca, cnt = 0;
  pot.clear();
  pot.push_back((node){0, 0, 0});
  int x = a, y = b, dis, fl = 1;
  while (top[a] != top[b])
    dep[top[a]] < dep[top[b]] ? b = fa[top[b]] : a = fa[top[a]];
  lca = dep[a] < dep[b] ? a : b, dis = dep[x] + dep[y] - 2 * dep[lca] + 1;
  a = x;
  while (dep[top[a]] > dep[lca])
    pot.push_back((node){a, top[a], cnt += dep[a] - dep[top[a]] + 1, 0}),
        a = fa[top[a]];
  if (a != lca)
    pot.push_back((node){a, lca, cnt += dep[a] - dep[lca] + 1, 0}), fl = 0;
  b = y;
  vec.clear(), cnt = dis;
  while (dep[top[b]] > dep[lca])
    vec.push_back((node){top[b], b, cnt, 1}), cnt -= dep[b] - dep[top[b]] + 1,
        b = fa[top[b]];
  if (b != lca)
    vec.push_back((node){lca, b, cnt, 1}), cnt -= dep[b] - dep[lca] + 1, fl = 0;
  if (fl) pot.push_back((node){lca, lca, cnt});
  for (int i = vec.size() - 1; ~i; --i) pot.push_back(vec[i]);
}
int main() {
  n = gi(), scanf("%s", ch + 1);
  for (int i = 1, u, v; i < n; ++i) u = gi(), v = gi(), lnk(u, v), lnk(v, u);
  dfs1(1, 0), dfs2(1, 0);
  pw[0] = make_pair(1, 1);
  for (int i = 1; i <= n; ++i) pw[i] = bs * pw[i - 1];
  for (int i = 1; i <= n; ++i) h1[i] = bs * h1[i - 1] + ch[ind[i]];
  for (int i = n; i >= 1; --i) h2[i] = bs * h2[i + 1] + ch[ind[i]];
  int Q = gi();
  while (Q--) {
    int a = gi(), b = gi(), c = gi(), d = gi(), ans = 0;
    get_string(a, b, sp0), get_string(c, d, sp1);
    for (int las = 0, i = 1, j = 1;;) {
      int cur;
      if (las == sp0[i].len) ++i;
      if (i == sp0.size()) break;
      if (las == sp1[j].len) ++j;
      if (j == sp1.size()) break;
      if (sp0[i].len < sp1[j].len)
        cur = sp0[i].len;
      else
        cur = sp1[j].len;
      if (Hash(sp0[i], las - sp0[i - 1].len + 1, cur - sp0[i - 1].len) ==
          Hash(sp1[j], las - sp1[j - 1].len + 1, cur - sp1[j - 1].len)) {
        ans = las = cur;
        continue;
      }
      int l = las, r = cur, mid;
      while (l < r - 1) {
        mid = (l + r) >> 1;
        if (Hash(sp0[i], las - sp0[i - 1].len + 1, mid - sp0[i - 1].len) ==
            Hash(sp1[j], las - sp1[j - 1].len + 1, mid - sp1[j - 1].len))
          l = mid;
        else
          r = mid;
      }
      ans = l;
      break;
    }
    printf("%d\n", ans);
  }
  return 0;
}