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 N = 3e5 + 10;
int n;
char node[N], seq[N * 2];
int head[N], to[N * 2], nxt[N * 2], cnt;
void addedge(int u, int v) {
  to[++cnt] = v;
  nxt[cnt] = head[u];
  head[u] = cnt;
}
int size[N], fa[N], hson[N], deep[N];
void dfs1(int x) {
  size[x] = 1;
  for (int i = head[x]; i; i = nxt[i]) {
    int y = to[i];
    if (y == fa[x]) continue;
    fa[y] = x, deep[y] = deep[x] + 1;
    dfs1(y);
    size[x] += size[y];
    if (size[y] > size[hson[x]]) hson[x] = y;
  }
}
int dfn[N], topf[N], dfsclock;
void dfs2(int x, int up) {
  dfn[x] = ++dfsclock;
  topf[x] = up;
  if (!hson[x]) return;
  dfs2(hson[x], up);
  for (int i = head[x]; i; i = nxt[i]) {
    int y = to[i];
    if (y == fa[x] || y == hson[x]) continue;
    dfs2(y, y);
  }
}
int lca(int x, int y) {
  while (topf[x] != topf[y]) {
    if (deep[topf[x]] > deep[topf[y]])
      x = fa[topf[x]];
    else
      y = fa[topf[y]];
  }
  return deep[x] < deep[y] ? x : y;
}
void divide(vector<pair<int, int> > &t, int x, int y) {
  t.clear();
  int goal = lca(x, y);
  while (topf[x] != topf[goal]) {
    t.push_back(make_pair(dfn[x], dfn[topf[x]]));
    x = fa[topf[x]];
  }
  t.push_back(make_pair(dfn[x], dfn[goal]));
  int mid = t.size();
  while (topf[y] != topf[goal]) {
    t.push_back(make_pair(dfn[topf[y]], dfn[y]));
    y = fa[topf[y]];
  }
  if (y != goal) t.push_back(make_pair(dfn[goal] + 1, dfn[y]));
  reverse(t.begin() + mid, t.end());
}
int sa[N * 2], rk[N * 2], vis[N * 2], tmp[N * 2], height[N * 2], nn, mm;
int *_ = tmp, st[N * 2][20];
void rsort() {
  for (int i = 1; i <= mm; ++i) vis[i] = 0;
  for (int i = 1; i <= nn; ++i) vis[rk[i]]++;
  for (int i = 1; i <= mm; ++i) vis[i] += vis[i - 1];
  for (int i = nn; i; --i) sa[vis[rk[tmp[i]]]--] = tmp[i];
}
void buildSA() {
  for (int i = 1; i <= n; ++i) seq[dfn[i]] = seq[2 * n + 2 - dfn[i]] = node[i];
  seq[n + 1] = '$';
  nn = 2 * n + 1, mm = 256;
  for (int i = 1; i <= nn; ++i) rk[i] = seq[i], tmp[i] = i;
  rsort();
  for (int w = 1, p = 0; p < nn; mm = p, w <<= 1) {
    p = 0;
    for (int i = nn - w + 1; i <= nn; ++i) tmp[++p] = i;
    for (int i = 1; i <= nn; ++i)
      if (sa[i] > w) tmp[++p] = sa[i] - w;
    rsort();
    swap(tmp, rk), rk[sa[1]] = 1, p = 1;
    for (int i = 2; i <= nn; ++i)
      rk[sa[i]] =
          (tmp[sa[i]] == tmp[sa[i - 1]] && tmp[sa[i] + w] == tmp[sa[i - 1] + w])
              ? p
              : ++p;
  }
  for (int i = 1, k = 0; i <= nn; ++i) {
    if (k) k--;
    int j = sa[rk[i] - 1];
    while (seq[i + k] == seq[j + k]) k++;
    height[rk[i]] = k;
  }
  _[0] = -1;
  for (int i = 1; i <= nn; ++i) _[i] = _[i >> 1] + 1, st[i][0] = height[i];
  for (int i = 1; (1 << i) <= nn; ++i)
    for (int j = 1; j <= nn - (1 << i) + 1; ++j)
      st[j][i] = min(st[j][i - 1], st[j + (1 << i - 1)][i - 1]);
}
int lcp(int x, int y) {
  if (x == y) return nn - x + 1;
  x = rk[x], y = rk[y];
  if (x > y) swap(x, y);
  ++x;
  int step = _[y - x + 1];
  return min(st[x][step], st[y - (1 << step) + 1][step]);
}
int seg_lcp(pair<int, int> x, pair<int, int> y) {
  int a = x.first, b = y.first;
  if (x.first > x.second) swap(x.first, x.second), a = 2 * n + 2 - a;
  if (y.first > y.second) swap(y.first, y.second), b = 2 * n + 2 - b;
  return min(lcp(a, b), min(x.second - x.first + 1, y.second - y.first + 1));
}
bool cut(pair<int, int> &seg, int val) {
  int len = abs(seg.second - seg.first) + 1;
  seg.first += val * ((seg.second > seg.first) ? 1 : -1);
  return val >= len;
}
vector<pair<int, int> > a, b;
int solve(int x1, int y1, int x2, int y2) {
  divide(a, x1, y1), divide(b, x2, y2);
  int i = 0, j = 0, ans = 0;
  bool flg = true;
  while (flg && i < a.size() && j < b.size()) {
    int val = seg_lcp(a[i], b[j]);
    ans += val;
    flg = false;
    if (cut(a[i], val)) ++i, flg = true;
    if (cut(b[j], val)) ++j, flg = true;
  }
  return ans;
}
inline int read() {
  int x = 0;
  char c = getchar();
  bool f = 0;
  while (c < '0' || c > '9') f |= (c == '-'), c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
  return f ? -x : x;
}
inline void write(int x) {
  char s[15] = {}, *p = s + 13;
  if (x < 0) putchar('-'), x = -x;
  do {
    *(--p) = x % 10 + '0';
    x /= 10;
  } while (x);
  puts(p);
}
void init() {
  n = read();
  scanf("%s", node + 1);
  for (int i = 1; i < n; ++i) {
    int u = read(), v = read();
    addedge(u, v), addedge(v, u);
  }
  dfs1(1), dfs2(1, 1);
  buildSA();
}
int main() {
  init();
  for (int q = read(); q; q--) {
    int x1 = read(), y1 = read(), x2 = read(), y2 = read();
    write(solve(x1, y1, x2, y2));
  }
}