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 <unsigned int P>
struct Z {
  static unsigned int add(unsigned int a, unsigned int b) {
    if ((a += b) >= P) a -= P;
    return a;
  }
  static unsigned int sub(unsigned int a, unsigned int b) {
    if ((a += P - b) >= P) a -= P;
    return a;
  }
  static unsigned int mul(unsigned int a, unsigned int b) {
    return 1ull * a * b % P;
  }
};
const unsigned int M1 = 998244353, M2 = 1000000007;
struct P {
  unsigned int a, b;
  static P from(unsigned int v) { return {v, v}; }
  friend P operator+(P const& l, P const& r) {
    return {Z<M1>::add(l.a, r.a), Z<M2>::add(l.b, r.b)};
  }
  friend P operator-(P const& l, P const& r) {
    return {Z<M1>::sub(l.a, r.a), Z<M2>::sub(l.b, r.b)};
  }
  friend P operator*(P const& l, P const& r) {
    return {Z<M1>::mul(l.a, r.a), Z<M2>::mul(l.b, r.b)};
  }
  friend bool operator==(P const& l, P const& r) {
    return l.a == r.a && l.b == r.b;
  }
};
const P B{33, 41};
const int N = 3e5;
int n, m;
char c[N + 2];
vector<int> g[N + 1];
int f[N + 1], dep[N + 1], sz[N + 1], son[N + 1];
void dfs0(int u) {
  sz[u] = 1;
  for (int v : g[u]) {
    if (v == f[u]) continue;
    f[v] = u;
    dep[v] = dep[u] + 1;
    dfs0(v);
    sz[u] += sz[v];
    if (sz[v] > sz[son[u]]) son[u] = v;
  }
}
int top[N + 1];
int cl, dfn[N + 1], nfd[N + 1];
void dfs1(int u, int t) {
  top[u] = t;
  ++cl;
  dfn[u] = cl;
  nfd[cl] = u;
  if (son[u]) dfs1(son[u], t);
  for (int v : g[u])
    if (v != f[u] && v != son[u]) dfs1(v, v);
}
int lca(int x, int y) {
  for (; top[x] != top[y]; y = f[top[y]])
    if (dep[top[x]] > dep[top[y]]) swap(x, y);
  if (dep[x] > dep[y]) swap(x, y);
  return x;
}
vector<pair<int, int> > path(int x, int y) {
  vector<pair<int, int> > u, d;
  int z = lca(x, y);
  for (; dep[top[x]] > dep[z]; x = f[top[x]]) u.emplace_back(x, top[x]);
  u.emplace_back(x, z);
  for (; dep[top[y]] > dep[z]; y = f[top[y]]) d.emplace_back(top[y], y);
  if (y != z) d.emplace_back(son[z], y);
  u.insert(u.end(), d.rbegin(), d.rend());
  return u;
}
P bpow[N + 1], h0[N + 2], h1[N + 2];
inline P geth(bool r, int p, int l) {
  return r ? h1[p - l + 1] - h1[p + 1] * bpow[l]
           : h0[p + l - 1] - h0[p - 1] * bpow[l];
}
int LCP(vector<pair<int, int> > A, vector<pair<int, int> > B) {
  auto a = A.begin(), b = B.begin();
  int lcp = 0;
  while (a != A.end() && b != B.end()) {
    int ab = dfn[a->first], ae = dfn[a->second], bb = dfn[b->first],
        be = dfn[b->second];
    bool ar = ab > ae, br = bb > be;
    int al = (ar ? ab - ae : ae - ab) + 1, bl = (br ? bb - be : be - bb) + 1,
        l = min(al, bl);
    if (geth(ar, ab, l) == geth(br, bb, l)) {
      if (l == al)
        ++a;
      else
        a->first = nfd[ab + (ar ? -l : l)];
      if (l == bl)
        ++b;
      else
        b->first = nfd[bb + (br ? -l : l)];
      lcp += l;
    } else {
      int L = 1, R = l, A = 0;
      while (L <= R) {
        int M = (L + R) >> 1;
        if (geth(ar, ab, M) == geth(br, bb, M)) {
          A = M;
          L = M + 1;
        } else
          R = M - 1;
      }
      lcp += A;
      break;
    }
  }
  return lcp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> c + 1;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs0(1);
  dfs1(1, 1);
  bpow[0] = P::from(1);
  for (int i = 1; i <= n; ++i) bpow[i] = bpow[i - 1] * B;
  for (int i = 1; i <= n; ++i) h0[i] = h0[i - 1] * B + P::from(c[nfd[i]] - 'a');
  for (int i = n; i >= 1; --i) h1[i] = h1[i + 1] * B + P::from(c[nfd[i]] - 'a');
  cin >> m;
  while (m--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << LCP(path(a, b), path(c, d)) << '\n';
  }
  return 0;
}