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 int MAXN = 300005;
const int MAXM = 600005;
template <typename T>
inline void read(T &AKNOI) {
  T x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  AKNOI = flag * x;
}
char ss[MAXN], s[MAXM];
int n, q;
vector<int> e[MAXN];
int fa[MAXN], dep[MAXN], siz[MAXN], son[MAXN], top[MAXN];
int dfn[MAXN], clk, t1, t2, t3;
pair<int, int> r1[100], r2[100], r3[100];
struct SuffixArray {
  int sa[MAXM], cnt[MAXM], x[MAXM], y[MAXM];
  int rnk[MAXM], hei[MAXM], lg2[MAXM], st[MAXM][20];
  inline bool cmp(int i, int j, int k) {
    return (y[i] == y[j] && y[i + k] == y[j + k]);
  }
  void build() {
    int m = 255;
    for (int i = 1; i <= n; ++i) {
      ++cnt[x[i] = s[i]];
    }
    for (int i = 1; i <= m; ++i) {
      cnt[i] += cnt[i - 1];
    }
    for (int i = n; i >= 1; --i) {
      sa[cnt[x[i]]--] = i;
    }
    for (int k = 1; k <= n; k <<= 1) {
      int p = 0;
      for (int i = n - k + 1; i <= n; ++i) {
        y[++p] = i;
      }
      for (int i = 1; i <= n; ++i) {
        if (sa[i] > k) {
          y[++p] = sa[i] - k;
        }
      }
      for (int i = 0; i <= m; ++i) {
        cnt[i] = 0;
      }
      for (int i = 1; i <= n; ++i) {
        ++cnt[x[y[i]]];
      }
      for (int i = 1; i <= m; ++i) {
        cnt[i] += cnt[i - 1];
      }
      for (int i = n; i >= 1; --i) {
        sa[cnt[x[y[i]]]--] = y[i];
      }
      swap(x, y);
      x[sa[1]] = p = 1;
      for (int i = 2; i <= n; ++i) {
        x[sa[i]] = (cmp(sa[i], sa[i - 1], k) ? p : ++p);
      }
      if (p >= n) break;
      m = p;
    }
    for (int i = 1; i <= n; ++i) {
      rnk[sa[i]] = i;
    }
    for (int i = 1, j = 0; i <= n; ++i) {
      if (j) --j;
      while (s[i + j] == s[sa[rnk[i] - 1] + j]) ++j;
      hei[rnk[i]] = j;
    }
    for (int i = 2; i <= n; ++i) {
      lg2[i] = lg2[i >> 1] + 1;
    }
    for (int i = n; i >= 1; --i) {
      st[i][0] = hei[i];
      for (int j = 1; i + (1 << j) - 1 <= n; ++j) {
        st[i][j] = min(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]);
      }
    }
  }
  inline int LCP(int l, int r) {
    if (l == r) return n - l + 1;
    l = rnk[l], r = rnk[r];
    if (l > r) swap(l, r);
    int k = lg2[r - l];
    return min(st[l + 1][k], st[r - (1 << k) + 1][k]);
  }
} SA;
void DFS1(int u) {
  siz[u] = 1;
  for (auto v : e[u]) {
    if (v == fa[u]) continue;
    fa[v] = u;
    dep[v] = dep[u] + 1;
    DFS1(v);
    if (siz[v] > siz[son[u]]) son[u] = v;
    siz[u] += siz[v];
  }
}
void DFS2(int u, int topf) {
  top[u] = topf;
  dfn[u] = ++clk;
  s[clk] = s[n * 2 + 2 - clk] = ss[u];
  if (son[u]) DFS2(son[u], topf);
  for (auto v : e[u]) {
    if (v == fa[u] || v == son[u]) continue;
    DFS2(v, v);
  }
}
void GetRoute(int u, int v, pair<int, int> *r, int &t) {
  while (top[u] ^ top[v]) {
    if (dep[top[u]] > dep[top[v]]) {
      r[++t] = make_pair(n - dfn[u] + 1, n - dfn[top[u]] + 1);
      u = fa[top[u]];
    } else {
      r3[++t3] = make_pair(dfn[top[v]], dfn[v]);
      v = fa[top[v]];
    }
  }
  if (dep[u] > dep[v]) {
    r[++t] = make_pair(n - dfn[u] + 1, n - dfn[v] + 1);
  } else {
    r[++t] = make_pair(dfn[u], dfn[v]);
  }
  while (t3) {
    r[++t] = r3[t3--];
  }
}
int GetAns() {
  int ret = 0;
  int i = 1, j = 1, pi = r1[1].first, pj = r2[1].first;
  for (; i <= t1 && j <= t2;) {
    int d1 = SA.LCP(pi, pj);
    int d2 = min(r1[i].second - pi + 1, r2[j].second - pj + 1);
    if (d1 < d2) {
      return ret + d1;
    }
    ret += d2;
    if (r1[i].second - pi + 1 == d2) {
      pi = r1[++i].first;
    } else {
      pi += d2;
    }
    if (r2[j].second - pj + 1 == d2) {
      pj = r2[++j].first;
    } else {
      pj += d2;
    }
  }
  return ret;
}
void init() {
  read(n);
  scanf("%s", ss + 1);
  for (int i = 1, u, v; i < n; ++i) {
    read(u);
    read(v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  DFS1(1);
  DFS2(1, 0);
  s[n + 1] = '#';
  n = n * 2 + 1;
  SA.build();
}
void solve() {
  read(q);
  while (q--) {
    t1 = t2 = 0;
    int u, v;
    read(u);
    read(v);
    GetRoute(u, v, r1, t1);
    read(u);
    read(v);
    GetRoute(u, v, r2, t2);
    printf("%d\n", GetAns());
  }
}
int main() {
  init();
  solve();
  return 0;
}