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;
int qread() {
  int x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x;
}
const int maxn = 300005;
const int mlog = 21;
const int H1 = 20160224;
const int mod1 = 998244353;
const int H2 = 23333333;
const int mod2 = 1e9 + 7;
int Add(int a, int b, int mod) { return a + b >= mod ? a + b - mod : a + b; }
int Sub(int a, int b, int mod) { return a - b < 0 ? a - b + mod : a - b; }
class Hash {
 public:
  int h1, h2;
  Hash(int _h1 = 0, int _h2 = 0) : h1(_h1), h2(_h2) {}
  Hash operator+(const Hash &o) const {
    return Hash(Add(h1, o.h1, mod1), Add(h2, o.h2, mod2));
  }
  Hash operator-(const Hash &o) const {
    return Hash(Sub(h1, o.h1, mod1), Sub(h2, o.h2, mod2));
  }
  Hash operator*(const Hash &o) const {
    return Hash(1LL * h1 * o.h1 % mod1, 1LL * h2 * o.h2 % mod2);
  }
  bool operator==(const Hash &o) const { return h1 == o.h1 && h2 == o.h2; }
} H(H1, H2);
int n, q;
char s[maxn];
vector<int> edge[maxn];
int par[maxn][mlog], dep[maxn], pos1[maxn], pos2[maxn], val1[maxn];
Hash hval[maxn][mlog], rval[maxn][mlog], pw[maxn];
void dfs(int x, int p, int d) {
  par[x][0] = p;
  hval[x][0] = rval[x][0] = Hash(s[x], s[x]);
  dep[x] = d;
  for (int j = 1; j <= (mlog - 1); j++) {
    par[x][j] = par[par[x][j - 1]][j - 1];
    hval[x][j] = hval[x][j - 1] * pw[j - 1] + hval[par[x][j - 1]][j - 1];
    rval[x][j] = rval[x][j - 1] + rval[par[x][j - 1]][j - 1] * pw[j - 1];
  }
  for (int i = 0; i < (int(edge[x].size())); i++)
    if (edge[x][i] != p) dfs(edge[x][i], x, d + 1);
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  int diff = dep[x] - dep[y];
  for (int i = 0; i < (mlog); i++)
    if ((diff >> i) & 1) x = par[x][i];
  if (x == y) return x;
  for (int i = mlog - 1; i >= 0; i--)
    if (par[x][i] != par[y][i]) x = par[x][i], y = par[y][i];
  return par[x][0];
}
int jump(int x, int d) {
  for (int i = 0; i < (mlog); i++)
    if ((d >> i) & 1) x = par[x][i];
  return x;
}
int calc_hh(int a, int b, int c, int d) {
  if (!a || !b || !c || !d || dep[a] < dep[b] || dep[c] < dep[d]) return 0;
  int len = 0;
  for (int i = mlog - 1; i >= 0; i--) {
    int aa = par[a][i], cc = par[c][i];
    if (aa && cc && dep[aa] >= dep[b] && dep[cc] >= dep[d] &&
        hval[a][i] == hval[c][i]) {
      a = aa;
      c = cc;
      len += (1 << i);
    }
  }
  if (s[a] == s[c]) len++;
  return len;
}
int calc_hr(int a, int b, int c, int d) {
  if (!a || !b || !c || !d || dep[a] < dep[b] || dep[c] >= dep[d]) return 0;
  int len = 0, cnt = 0, diff = dep[d] - dep[c];
  for (int i = 0; i < (mlog); i++)
    if ((diff >> i) & 1) {
      pos1[++cnt] = d;
      val1[cnt] = i;
      d = par[d][i];
    }
  for (int i = cnt; i >= 1; i--) {
    int aa = par[a][val1[i]], dd = pos1[i];
    if (aa && dep[aa] >= dep[b] && rval[dd][val1[i]] == hval[a][val1[i]]) {
      a = aa;
      len += (1 << val1[i]);
    } else {
      d = dd;
      for (int j = val1[i] - 1; j >= 0; j--) {
        int aa = par[a][j];
        dd = par[d][j];
        if (aa && dd && dep[aa] >= dep[b] && dep[dd] > dep[c] &&
            rval[dd][j] == hval[a][j]) {
          a = aa;
          len += (1 << j);
        } else
          d = dd;
      }
      if (dep[d] > dep[c] && s[a] == s[d]) len++;
      return len;
    }
  }
  return len;
}
int calc_rr(int a, int b, int c, int d) {
  if (!a || !b || !c || !d || dep[a] >= dep[b] || dep[c] >= dep[d]) return 0;
  if (dep[b] - dep[a] > dep[d] - dep[c]) {
    swap(a, c);
    swap(b, d);
  }
  d = jump(d, dep[d] - dep[c] - (dep[b] - dep[a]));
  int len = 0, cnt = 0, diff = dep[b] - dep[a];
  for (int i = 0; i < (mlog); i++)
    if ((diff >> i) & 1) {
      pos1[++cnt] = b;
      b = par[b][i];
      pos2[cnt] = d;
      d = par[d][i];
      val1[cnt] = i;
    }
  for (int i = cnt; i >= 1; i--) {
    int bb = pos1[i], dd = pos2[i];
    if (rval[bb][val1[i]] == rval[dd][val1[i]])
      len += (1 << val1[i]);
    else {
      b = bb;
      d = dd;
      for (int j = val1[i] - 1; j >= 0; j--) {
        int bb = par[b][j], dd = par[d][j];
        if (bb && dd && dep[bb] > dep[a] && dep[dd] > dep[c] &&
            rval[bb][j] == rval[dd][j])
          len += (1 << j);
        else
          b = bb, d = dd;
      }
      break;
    }
  }
  return len;
}
int main() {
  n = qread();
  scanf("%s", s + 1);
  for (int i = 1; i <= (n - 1); i++) {
    int u = qread(), v = qread();
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  pw[0] = H;
  for (int i = 1; i <= (mlog - 1); i++) pw[i] = pw[i - 1] * pw[i - 1];
  dfs(1, 0, 0);
  q = qread();
  while (q--) {
    int a = qread(), b = qread(), c = qread(), d = qread();
    int vab = lca(a, b), vcd = lca(c, d);
    if (dep[a] - dep[vab] < dep[c] - dep[vcd]) {
      swap(a, c);
      swap(b, d);
      swap(vab, vcd);
    }
    int ans = calc_hh(a, vab, c, vcd);
    if (ans < dep[c] - dep[vcd] + 1) {
      printf("%d\n", ans);
      continue;
    }
    ans += calc_hr(jump(a, dep[c] - dep[vcd] + 1), vab, vcd, d);
    if (ans < dep[a] - dep[vab] + 1) {
      printf("%d\n", ans);
      continue;
    }
    ans += calc_rr(vab, b,
                   jump(d, dep[d] - dep[vcd] - (ans - (dep[c] - dep[vcd] + 1))),
                   d);
    printf("%d\n", ans);
  }
  return 0;
}