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>
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize(2)
using namespace std;
inline int read() {
  int x = 0;
  bool op = 0;
  char c = getchar();
  while (!isdigit(c)) op |= (c == '-'), c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return op ? -x : x;
}
const int N = 300010;
const int Mod = 998244353;
const long long base = 31;
int n, m;
int tot, A, B, C, D, dis1, dis2, l1, l2;
int head[N], to[N * 2], nxt[N * 2], dep[N], dp[N][25], d[N], son[N], lg[N],
    top[N];
long long pw[N], hs1[N], hs2[N], inv[N];
char ch[N];
vector<int> s[N], f[N];
long long mod(long long x) { return x >= 0 ? x % Mod : x % Mod + Mod; }
int ksm(long long x, int k) {
  if (k == 0) return 1;
  long long tmp = ksm(x, k >> 1);
  if (k & 1) return mod(mod(tmp * tmp) * x);
  return mod(tmp * tmp);
}
void addedge(int u, int v) {
  to[++tot] = v;
  nxt[tot] = head[u];
  head[u] = tot;
  return;
}
void pre(int u, int fa) {
  d[u] = dep[u] = dep[fa] + 1;
  son[u] = -1;
  dp[u][0] = fa;
  hs1[u] = mod(mod(hs1[fa] * base) + (ch[u] - 'a' + 1));
  hs2[u] = mod(hs2[fa] + mod((ch[u] - 'a' + 1) * pw[dep[u] - 1]));
  for (int i = 1; i <= 20; i++) {
    dp[u][i] = dp[dp[u][i - 1]][i - 1];
  }
  for (int i = head[u]; i; i = nxt[i]) {
    if (to[i] == fa) continue;
    pre(to[i], u);
    if (d[to[i]] > d[u]) {
      d[u] = d[to[i]];
      son[u] = to[i];
    }
  }
  return;
}
int lca(int u, int v) {
  if (dep[u] > dep[v]) swap(u, v);
  for (int i = 20; i >= 0; i--) {
    if (dep[dp[v][i]] >= dep[u]) {
      v = dp[v][i];
    }
  }
  if (u == v) return u;
  for (int i = 20; i >= 0; i--) {
    if (dp[u][i] ^ dp[v][i]) {
      u = dp[u][i];
      v = dp[v][i];
    }
  }
  return dp[u][0];
}
int jump(int x, int k) {
  if (k == 0) return x;
  x = dp[x][lg[k]];
  k -= (1 << lg[k]);
  k -= dep[x] - dep[top[x]];
  x = top[x];
  if (x == 0) return 0;
  return k >= 0 ? f[x][k] : s[x][-k];
}
bool check(int mid) {
  long long val1, val2;
  if (mid <= dis1 + 1) {
    int t = jump(A, mid);
    val1 = mod(mod(hs2[A] - hs2[t]) * inv[dep[t]]);
  } else {
    int t = jump(B, (dep[B] - dep[l1]) - (mid - dis1 - 1));
    val1 = mod(mod(mod(mod(hs2[A] - hs2[dp[l1][0]]) * inv[dep[dp[l1][0]]]) *
                   pw[mid - dis1 - 1]) +
               mod(hs1[t] - mod(hs1[l1] * pw[mid - dis1 - 1])));
  }
  if (mid <= dis2 + 1) {
    int t = jump(C, mid);
    val2 = mod(mod(hs2[C] - hs2[t]) * inv[dep[t]]);
  } else {
    int t = jump(D, (dep[D] - dep[l2]) - (mid - dis2 - 1));
    val2 = mod(mod(mod(mod(hs2[C] - hs2[dp[l2][0]]) * inv[dep[dp[l2][0]]]) *
                   pw[mid - dis2 - 1]) +
               mod(hs1[t] - mod(hs1[l2] * pw[mid - dis2 - 1])));
  }
  if (val1 == val2) return true;
  return false;
}
void dfs1(int u, int fa) {
  son[u] = -1;
  for (int i = head[u]; i; i = nxt[i]) {
    if (to[i] == fa) continue;
    dfs1(to[i], u);
    if (d[to[i]] > d[u]) {
      d[u] = d[to[i]];
      son[u] = to[i];
    }
  }
  return;
}
void dfs2(int u, int fa, int t) {
  top[u] = t;
  if (u == t) {
    for (int i = 0, o = u; i <= d[u] - dep[u]; i++) {
      f[u].push_back(o);
      o = dp[o][0];
    }
    for (int i = 0, o = u; i <= d[u] - dep[u]; i++) {
      s[u].push_back(o);
      o = son[o];
    }
  }
  if (son[u] == -1) return;
  dfs2(son[u], u, t);
  for (int i = head[u]; i; i = nxt[i]) {
    if (to[i] == fa || to[i] == son[u]) continue;
    dfs2(to[i], u, to[i]);
  }
  return;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    scanf("%c", &ch[i]);
  }
  for (int i = 1; i < n; i++) {
    int u = read(), v = read();
    addedge(u, v);
    addedge(v, u);
  }
  pw[0] = inv[0] = 1;
  lg[0] = -1;
  long long tmp = ksm(base, Mod - 2);
  for (int i = 1; i <= n; i++) {
    pw[i] = mod(pw[i - 1] * base);
    inv[i] = mod(inv[i - 1] * tmp);
    lg[i] = lg[i >> 1] + 1;
  }
  pre(1, 0);
  dfs2(1, 0, 1);
  m = read();
  for (int i = 1; i <= m; i++) {
    A = read();
    B = read();
    C = read();
    D = read();
    l1 = lca(A, B);
    l2 = lca(C, D);
    dis1 = dep[A] - dep[l1];
    dis2 = dep[C] - dep[l2];
    int lef = -1, rig = min(dep[A] + dep[B] - 2 * dep[l1],
                            dep[C] + dep[D] - 2 * dep[l2]) +
                        2;
    while (lef + 1 < rig) {
      int mid = lef + rig >> 1;
      if (check(mid))
        lef = mid;
      else
        rig = mid;
    }
    printf("%d\n", lef);
  }
  return 0;
}