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 <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T, class T1>
inline void gn(T &first, T1 &second) {
  gn(first);
  gn(second);
}
template <class T, class T1, class T2>
inline void gn(T &first, T1 &second, T2 &z) {
  gn(first);
  gn(second);
  gn(z);
}
template <class T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <class T>
inline void printsp(T first) {
  print(first);
  putchar(' ');
}
template <class T>
inline void println(T first) {
  print(first);
  putchar('\n');
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
char str[300010];
int head[300010], nxt[300010 << 1], to[300010 << 1];
int pa[300010][19], dep[300010], ord[300010 << 1][19], N, E;
pair<pair<int, int>, int> pos[300010 << 1];
void init() {
  for (int i = 1; i <= N; i++) head[i] = -1;
}
void add(int u, int v) {
  to[E] = v, nxt[E] = head[u], head[u] = E++;
  to[E] = u, nxt[E] = head[v], head[v] = E++;
}
void dfs(int u) {
  for (int i = 1; i < 19; i++) pa[u][i] = pa[pa[u][i - 1]][i - 1];
  for (int e = head[u]; ~e; e = nxt[e]) {
    int v = to[e];
    if (v == pa[u][0]) continue;
    pa[v][0] = u, dep[v] = dep[u] + 1;
    dfs(v);
  }
}
void TreeSuffixArray() {
  for (int i = 1; i <= N; i++) ord[i][0] = str[i], ord[i + N][0] = str[i];
  for (int k = 1; k < 19; k++) {
    for (int i = 1; i <= N; i++) {
      int u = pa[i][k - 1];
      if (u) {
        pos[i] = pair<pair<int, int>, int>(
            pair<int, int>(ord[i][k - 1], ord[u][k - 1]), i);
        pos[i + N] = pair<pair<int, int>, int>(
            pair<int, int>(ord[u + N][k - 1], ord[i + N][k - 1]), i + N);
      } else {
        pos[i] = pair<pair<int, int>, int>(pair<int, int>(ord[i][k - 1], 0), i);
        pos[i + N] = pair<pair<int, int>, int>(
            pair<int, int>(0, ord[i + N][k - 1]), i + N);
      }
    }
    sort(pos + 1, pos + N + N + 1);
    int cnt = 0;
    for (int i = 1; i <= N + N; i++) {
      ord[pos[i].second][k] = cnt + 1;
      cnt += (pos[i].first != pos[i + 1].first);
    }
  }
}
int kth(int u, int k) {
  for (int i = 0; i < 19; i++)
    if ((((k) >> (i)) & 1)) u = pa[u][i];
  return u;
}
int lca(int u, int v) {
  if (dep[u] > dep[v]) swap(u, v);
  for (int i = 19 - 1; i >= 0; i--)
    if (dep[pa[v][i]] >= dep[u]) v = pa[v][i];
  if (u == v) return u;
  for (int i = 19 - 1; i >= 0; i--)
    if (pa[u][i] != pa[v][i]) u = pa[u][i], v = pa[v][i];
  return pa[u][0];
}
int lcp(int a, int b, int len) {
  if (!len) return 0;
  int ans = 0;
  for (int i = 19 - 1; i >= 0; i--) {
    int A = a, B = b;
    if (ans + (1 << i) > len) continue;
    if (a > N) A = kth(a - N, len - ans - (1 << i)) + N;
    if (b > N) B = kth(b - N, len - ans - (1 << i)) + N;
    if (ord[A][i] == ord[B][i]) {
      ans += (1 << i);
      if (a <= N) a = pa[a][i];
      if (b <= N) b = pa[b][i];
    }
  }
  return ans;
}
int solve(int a, int b, int c, int d) {
  int ab = lca(a, b);
  int cd = lca(c, d);
  if (dep[a] - dep[ab] < dep[c] - dep[cd]) {
    swap(a, c), swap(b, d), swap(ab, cd);
  }
  int len = dep[c] - dep[cd];
  int ans = lcp(a, c, len);
  if (ans < len) return ans;
  a = kth(a, len);
  int d1 = dep[a] - dep[ab] + 1;
  int d2 = dep[d] - dep[cd] + 1;
  if (d1 >= d2) return ans + lcp(a, d + N, d2);
  int dd = kth(d, d2 - d1);
  int add = lcp(a, dd + N, d1);
  ans += add;
  if (add < d1) return ans;
  d1 = dep[b] - dep[ab];
  d2 = dep[d] - dep[dd];
  if (d1 > d2)
    b = kth(b, d1 - d2);
  else
    d = kth(d, d2 - d1);
  return ans + lcp(b + N, d + N, min(d1, d2));
}
int main() {
  int a, b, c, d, q;
  scanf("%d", &N);
  scanf("%s", str + 1);
  init();
  for (int i = 1; i < N; i++) gn(a, b), add(a, b);
  dep[1] = 1;
  dfs(1);
  TreeSuffixArray();
  for (gn(q); q--;) {
    gn(a, b);
    gn(c, d);
    println(solve(a, b, c, d));
  }
  return 0;
}