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 MOD = 1000000007;
const int MAXN = 300005;
const int K = 20;
unsigned long long U[MAXN];
int clz[1 << K];
int N, M;
char S[MAXN];
vector<int> adj[MAXN];
int dep[MAXN];
int par[K][MAXN];
unsigned long long up[MAXN], dn[MAXN];
int far[MAXN], lc[MAXN];
int L, id[MAXN], pos[MAXN];
vector<int> path[MAXN];
void dfs1(int v, int p, int d) {
  dep[v] = d;
  par[0][v] = p;
  up[v] = (P * up[p] + S[v]) % MOD;
  dn[v] = (Q * dn[p] + S[v]) % MOD;
  for (int n : adj[v]) {
    if (n == p) continue;
    dfs1(n, v, d + 1);
  }
}
void dfs2(int v, int p) {
  far[v] = 1;
  for (int n : adj[v]) {
    if (n == p) continue;
    dfs2(n, v);
    if (far[n] + 1 > far[v]) {
      lc[v] = n;
      far[v] = far[n] + 1;
    }
  }
}
void dfs3(int v, int p, int i, int d) {
  id[v] = i;
  pos[v] = d;
  for (int n : adj[v]) {
    if (n == p) continue;
    if (n == lc[v]) continue;
    dfs3(n, v, L++, 0);
  }
  if (lc[v] > 0) {
    dfs3(lc[v], v, i, d + 1);
  }
}
inline int jump(int a, int d) {
  if (d == 0) return a;
  int k = clz[d];
  a = par[k][a];
  d ^= 1 << k;
  return path[id[a]][pos[a] - d];
}
inline int lca(int a, int b) {
  if (dep[a] < dep[b]) swap(a, b);
  int d = dep[a] - dep[b];
  while (d > 0) {
    int k = clz[d];
    a = par[k][a];
    d ^= 1 << k;
  }
  if (a == b) return a;
  for (int i = K - 1; i >= 0; i -= 4) {
    if (par[i][a] != par[i][b]) {
      a = par[i][a];
      b = par[i][b];
    }
    if (par[i - 1][a] != par[i - 1][b]) {
      a = par[i - 1][a];
      b = par[i - 1][b];
    }
    if (par[i - 2][a] != par[i - 2][b]) {
      a = par[i - 2][a];
      b = par[i - 2][b];
    }
    if (par[i - 3][a] != par[i - 3][b]) {
      a = par[i - 3][a];
      b = par[i - 3][b];
    }
  }
  return par[0][a];
}
inline unsigned long long get(int a, int b, int l, int k) {
  if (k <= dep[a] - dep[l]) {
    int v = jump(a, k);
    return (up[a] - U[k] * up[v] % MOD + MOD) % MOD;
  } else {
    int da = dep[a] - dep[l];
    int db = dep[b] - dep[l];
    int v = jump(b, da + db + 1 - k);
    int dv = dep[v] - dep[l];
    unsigned long long up_hash = (up[a] - U[da] * up[l] % MOD + MOD) % MOD;
    unsigned long long dn_hash = (U[dv] * dn[v] % MOD - dn[l] + MOD) % MOD;
    return (up_hash + U[da] * (S[l] + dn_hash)) % MOD;
  }
}
void init() {
  U[0] = 1;
  for (int i = 0; i < MAXN; i++) {
    U[i + 1] = P * U[i] % MOD;
  }
  for (int i = 0; i < 1 << K; i++) {
    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);
  }
  dep[0] = -1;
  dfs1(1, 0, 0);
  dfs2(1, 0);
  dfs3(1, 0, L++, 0);
  for (int i = 0; i + 1 < K; i++) {
    for (int j = 1; j <= N; j++) {
      par[i + 1][j] = par[i][par[i][j]];
    }
  }
  for (int i = 1; i <= N; i++) {
    if (pos[i] == 0) {
      int k = id[i];
      int v = par[0][i];
      pos[i] += min(dep[i], far[i]);
      for (int j = 0; j < pos[i]; j++) {
        path[k].push_back(v);
        v = par[0][v];
      }
      reverse(path[k].begin(), path[k].end());
      v = i;
      while (v > 0) {
        if (v != i) pos[v] += pos[i];
        path[k].push_back(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 = dep[a] + dep[b] - 2 * dep[l] + 1;
    int v = dep[c] + dep[d] - 2 * dep[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();
  cerr << clock() / 1e6 << endl;
  build();
  cerr << clock() / 1e6 << endl;
  solve();
  cerr << clock() / 1e6 << endl;
}