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;
const unsigned long long P = 127;
const unsigned long long Q = 480314964;
const unsigned long long R = 1000000007;
const int MAXN = 300005;
const int K = 19;
unsigned long long U[MAXN];
int clz[1 << K];
int N, M;
char S[MAXN];
vector<int> adj[MAXN];
unsigned long long up[MAXN], dn[MAXN];
int A[K][MAXN], D[MAXN];
int far[MAXN], lc[MAXN];
int *id[MAXN], ch[MAXN];
int path[2 * MAXN], *ptr = path;
void dfs(int v, int p) {
  A[0][v] = p;
  D[v] = D[p] + 1;
  up[v] = (P * up[p] + S[v]) % R;
  dn[v] = (Q * dn[p] + S[v]) % R;
  for (int n : adj[v]) {
    if (n == p) continue;
    dfs(n, v);
    if (far[n] + 1 > far[v]) {
      lc[v] = n;
      far[v] = far[n] + 1;
    }
  }
  ch[lc[v]] = 1;
}
inline int jump(int a, int d) {
  if (d == 0) return a;
  int k = clz[d];
  d ^= 1 << k;
  return id[A[k][a]][-d];
}
inline int lca(int a, int b) {
  if (D[a] < D[b]) swap(a, b);
  a = jump(a, D[a] - D[b]);
  if (a == b) return a;
  for (int i = K - 1; i >= 0; i--) {
    if (A[i][a] != A[i][b]) {
      a = A[i][a];
      b = A[i][b];
    }
  }
  return A[0][a];
}
inline unsigned long long get(int a, int b, int l, int k) {
  if (k <= D[a] - D[l]) {
    int v = jump(a, k);
    return (up[a] - U[k] * up[v] % R + R) % R;
  } else {
    int da = D[a] - D[l];
    int db = D[b] - D[l];
    int v = jump(b, da + db + 1 - k);
    int dv = D[v] - D[l];
    unsigned long long up_hash = (up[a] - U[da] * up[l] % R + R) % R;
    unsigned long long dn_hash = (U[dv] * dn[v] % R - dn[l] + R) % R;
    return (up_hash + U[da] * (S[l] + dn_hash)) % R;
  }
}
void init() {
  U[0] = 1;
  for (int i = 0; i < MAXN; i++) {
    U[i + 1] = P * U[i] % R;
    clz[i] = 31 - __builtin_clz(i);
  }
}
void build() {
  scanf("%d%s", &N, S + 1);
  for (int i = 1; i < N; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  D[0] = -1;
  dfs(1, 0);
  for (int i = 0; i + 1 < K; i++) {
    for (int j = 1; j <= N; j++) {
      A[i + 1][j] = A[i][A[i][j]];
    }
  }
  for (int i = 1; i <= N; i++) {
    if (ch[i]) continue;
    int u = A[0][i], v = i;
    int k = min(D[i], far[i]);
    for (int j = 1; j <= k; j++) {
      ptr[k - j] = u;
      u = A[0][u];
    }
    ptr += k;
    while (v > 0) {
      id[v] = ptr;
      *ptr++ = v;
      v = lc[v];
    }
  }
}
void solve() {
  scanf("%d", &M);
  for (int i = 0; i < M; i++) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int l = lca(a, b), m = lca(c, d);
    int u = D[a] + D[b] - 2 * D[l] + 1;
    int v = D[c] + D[d] - 2 * D[m] + 1;
    int lo = 0, hi = min(u, v) + 1;
    while (lo + 1 < hi) {
      int mid = (lo + hi) / 2;
      unsigned long long g = get(a, b, l, mid);
      unsigned long long h = get(c, d, m, mid);
      (g == h ? lo : hi) = mid;
    }
    printf("%d\n", lo);
  }
}
int main() {
  init();
  build();
  solve();
}