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;
template <class T>
inline void chkmin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline void chkmax(T &a, T b) {
  if (a < b) a = b;
}
inline void myassert(bool a, string s) {
  if (!a) cerr << s << endl, exit(0);
}
inline int read() {
  int s = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') ch = getchar(), f = -1;
  while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar();
  return ~f ? s : -s;
}
const int maxn = 3e5 + 20;
vector<int> ed[maxn];
int dfn[maxn], low[maxn], times, top[maxn], son[maxn], sz[maxn], fa[maxn],
    deep[maxn];
int id[maxn];
void dfs(int u) {
  sz[u] = 1;
  for (int v : ed[u]) {
    if (v == fa[u]) continue;
    deep[v] = deep[u] + 1;
    fa[v] = u;
    dfs(v);
    sz[u] += sz[v];
    if (sz[son[u]] < sz[v]) son[u] = v;
  }
}
void dfs1(int u) {
  dfn[u] = ++times;
  id[times] = u;
  if (son[u]) top[son[u]] = top[u], dfs1(son[u]);
  for (int v : ed[u]) {
    if (v == fa[u] || v == son[u]) continue;
    top[v] = v;
    dfs1(v);
  }
  low[u] = times;
}
inline int lca(int u, int v) {
  while (top[u] != top[v]) {
    if (deep[top[u]] > deep[top[v]]) swap(u, v);
    v = fa[top[v]];
  }
  if (deep[u] > deep[v]) swap(u, v);
  return u;
}
int n;
char str[maxn];
int s[maxn], s1[maxn], p2[maxn];
const int seed = 181;
const int mod = 1e9 + 9;
inline void init() {
  n = read();
  scanf("%s", str + 1);
  for (int i = (1), _end_ = (n - 1); i <= _end_; i++) {
    int u = read(), v = read();
    ed[u].push_back(v);
    ed[v].push_back(u);
  }
  deep[1] = 1;
  dfs(1);
  top[1] = 1;
  dfs1(1);
  p2[0] = 1;
  for (int i = (1), _end_ = (n); i <= _end_; i++)
    p2[i] = (long long)p2[i - 1] * seed % mod;
  for (int i = (1), _end_ = (n); i <= _end_; i++)
    s[i] = ((long long)s[i - 1] * seed + str[id[i]] - 'a' + 1) % mod;
  for (int i = (n), _end_ = (1); i >= _end_; i--)
    s1[i] = ((long long)s1[i + 1] * seed + str[id[i]] - 'a' + 1) % mod;
}
inline vector<pair<int, int> > Get(int u, int v) {
  vector<pair<int, int> > A, B;
  int t = lca(u, v);
  while (top[u] != top[t]) {
    A.push_back(make_pair(dfn[u], dfn[top[u]]));
    u = fa[top[u]];
  }
  A.push_back(make_pair(dfn[u], dfn[t]));
  while (top[v] != top[t]) {
    B.push_back(make_pair(dfn[top[v]], dfn[v]));
    v = fa[top[v]];
  }
  if (v != t) B.push_back(make_pair(dfn[t] + 1, dfn[v]));
  for (int i = (((int)B.size()) - 1), _end_ = (0); i >= _end_; i--)
    A.push_back(B[i]);
  return A;
}
inline int check(int l, int r) {
  if (l <= r)
    return ((s[r] - (long long)s[l - 1] * p2[r - l + 1]) % mod + mod) % mod;
  else
    return ((s1[r] - (long long)s1[l + 1] * p2[l - r + 1]) % mod + mod) % mod;
}
inline int Lowerbound(int l1, int r1, int l2, int r2) {
  int len = abs(r1 - l1) + 1;
  int l = 0, r = len - 1;
  while (l < r) {
    int mid = l + r + 1 >> 1;
    int R1 = l1 <= r1 ? l1 + mid - 1 : l1 - mid + 1,
        R2 = l2 <= r2 ? l2 + mid - 1 : l2 - mid + 1;
    if (check(l1, R1) == check(l2, R2))
      l = mid;
    else
      r = mid - 1;
  }
  return l;
}
inline void doing() {
  int q = read();
  while (q--) {
    int a = read(), b = read();
    vector<pair<int, int> > A = Get(a, b);
    int c = read(), d = read();
    vector<pair<int, int> > B = Get(c, d);
    int ans = 0;
    for (int i = 0, j = 0; i < ((int)A.size()) && j < ((int)B.size());) {
      int lena = abs(A[i].second - A[i].first) + 1,
          lenb = abs(B[j].second - B[j].first) + 1;
      int l1 = A[i].first, r1 = A[i].second, l2 = B[j].first, r2 = B[j].second;
      int len = min(lena, lenb);
      int R1, R1n, R2, R2n;
      if (l1 <= r1)
        R1 = l1 + len - 1, R1n = l1 + len;
      else
        R1 = l1 - len + 1, R1n = l1 - len;
      if (l2 <= r2)
        R2 = l2 + len - 1, R2n = l2 + len;
      else
        R2 = l2 - len + 1, R2n = l2 - len;
      if (lena == lenb) {
        if (check(l1, r1) == check(l2, r2))
          i++, j++, ans += len;
        else {
          ans += Lowerbound(l1, r1, l2, r2);
          break;
        }
      } else if (lena < lenb) {
        if (check(l1, R1) == check(l2, R2))
          i++, B[j].first = R2n, ans += len;
        else {
          ans += Lowerbound(l1, R1, l2, R2);
          break;
        }
      } else {
        if (check(l1, R1) == check(l2, R2))
          j++, A[i].first = R1n, ans += len;
        else {
          ans += Lowerbound(l1, R1, l2, R2);
          break;
        }
      }
    }
    printf("%d\n", ans);
  }
}
int main() {
  init();
  doing();
  return 0;
}