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 long long mod = 1000000007;
const long long hsh1 = 1610612741;
const long long p1 = 37;
const long long hsh2 = 805306457;
const long long p2 = 31;
const int mxN = 300010;
const int lg = 20;
string s;
vector<int> g[mxN];
int par[mxN][lg];
int h[mxN];
long long hsh[mxN][lg];
long long rhsh[mxN][lg];
long long pw1[mxN], pw2[mxN];
long long comb(const long long h1, const long long h2, const int len) {
  long long fs = h1 >> 32, sc = h1 & ((1ll << 32) - 1);
  long long fs2 = h2 >> 32, sc2 = h2 & ((1ll << 32) - 1);
  fs = (fs + fs2 * pw1[len]) % hsh1;
  sc = (sc + sc2 * pw2[len]) % hsh2;
  return (fs << 32) + sc;
}
void dfs(const int v = 0, const int p = -1) {
  h[v] = (p == -1 ? 0 : h[p] + 1);
  par[v][0] = p;
  hsh[v][0] = rhsh[v][0] = ((1ll * (s[v] - 'a' + 1)) << 32 | (s[v] - 'a' + 1));
  for (int i = 1; par[v][i - 1] != -1; i++) {
    par[v][i] = par[par[v][i - 1]][i - 1];
    hsh[v][i] = comb(hsh[v][i - 1], hsh[par[v][i - 1]][i - 1], (1 << (i - 1)));
    rhsh[v][i] =
        comb(rhsh[par[v][i - 1]][i - 1], rhsh[v][i - 1], (1 << (i - 1)));
  }
  for (auto u : g[v]) {
    if (u != p) dfs(u, v);
  }
}
int lca(int u, int v) {
  if (h[u] > h[v]) swap(u, v);
  for (int i = lg - 1; i >= 0; i--) {
    if (par[v][i] != -1 && h[par[v][i]] >= h[u]) v = par[v][i];
  }
  if (u == v) return u;
  for (int i = lg - 1; i >= 0; i--) {
    if (par[v][i] != par[u][i]) v = par[v][i], u = par[u][i];
  }
  return par[v][0];
}
int getK(int v, const int k) {
  for (int i = 0; (1 << i) <= k; i++)
    if (k & (1 << i)) v = par[v][i];
  return v;
}
int getLCP(int a, int b, int len, bool r1, bool r2) {
  if (len == 0) return 0;
  int sofar = 0;
  for (int i = lg - 1; i >= 0; i--) {
    if (sofar + (1 << i) > len) continue;
    int v1 = a;
    if (r1) v1 = getK(a, len - sofar - (1 << i));
    int v2 = b;
    if (r2) v2 = getK(b, len - sofar - (1 << i));
    if ((r1 ? rhsh : hsh)[v1][i] == (r2 ? rhsh : hsh)[v2][i]) {
      if (!r1) a = par[a][i];
      if (!r2) b = par[b][i];
      sofar += (1 << i);
    }
  }
  return sofar;
}
int solve(int a, int b, int c, int d) {
  int l1 = lca(a, b), l2 = lca(c, d);
  if (h[a] - h[l1] < h[c] - h[l2]) {
    swap(a, c), swap(b, d), swap(l1, l2);
  }
  int d1 = h[a] - h[l1], d2 = h[c] - h[l2];
  int res = 0, cur = 0;
  cur = getLCP(a, c, d2, false, false);
  res = cur;
  if (cur != d2) return res;
  a = getK(a, d2);
  d1 = h[a] - h[l1] + 1;
  d2 = h[d] - h[l2] + 1;
  if (d1 >= d2) return res + getLCP(a, d, d2, false, true);
  c = getK(d, d2 - d1);
  cur = getLCP(a, c, d1, false, true);
  res += cur;
  if (cur != d1) return res;
  d2 = h[d] - h[c];
  d1 = h[b] - h[l1];
  if (d1 >= d2)
    b = getK(b, d1 - d2);
  else
    d = getK(d, d2 - d1);
  return res + getLCP(b, d, min(d1, d2), true, true);
}
int main(int argc, char** argv) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(par, -1, sizeof par);
  pw1[0] = pw2[0] = 1;
  for (int i = 1; i < mxN; i++)
    pw1[i] = p1 * pw1[i - 1] % hsh1, pw2[i] = p2 * pw2[i - 1] % hsh2;
  int N, M, u, v, a, b;
  cin >> N >> s;
  for (int i = 1; i < N; i++) {
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs();
  cin >> M;
  while (M--) {
    cin >> u >> v >> a >> b;
    u--, v--, a--, b--;
    cout << solve(u, v, a, b) << '\n';
  }
  return 0;
}