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>
const int N = 3e5 + 53, LN = 19;
int read() {
  int x = 0;
  char c = getchar();
  while (c < 48) c = getchar();
  while (c > 47) x = x * 10 + (c - 48), c = getchar();
  return x;
}
struct edge {
  int to, next;
} e[N << 1];
int n, head[N], cnt;
char s[N];
void addedge(int x, int y) {
  e[++cnt] = (edge){y, x[head]}, x[head] = cnt;
  e[++cnt] = (edge){x, y[head]}, y[head] = cnt;
}
template <int P, int base>
struct qwq {
  struct mod_t {
    static int norm(int x) { return x + (x >> 31 & P); }
    int x;
    mod_t() {}
    mod_t(int v) : x(v) {}
    mod_t(long long v) : x(v) {}
    mod_t(char v) : x(v) {}
    mod_t operator+(const mod_t& rhs) const { return norm(x + rhs.x - P); }
    mod_t operator-(const mod_t& rhs) const { return norm(x - rhs.x); }
    mod_t operator*(const mod_t& rhs) const { return (long long)x * rhs.x % P; }
  };
  static mod_t fpw(mod_t x, int y) {
    mod_t r = 1;
    for (; y; y >>= 1, x = x * x)
      if (y & 1) r = r * x;
    return r;
  }
  mod_t pw[N], ipw[N], ha[N], rha[N];
  int dep[N];
  qwq() {}
  void dfs(int x, int p, int d) {
    x[dep] = d;
    x[ha] = p[ha] * base + x[s];
    x[rha] = p[rha] + mod_t(x[s]) * d[pw];
    for (int i = x[head], nx; i; i = e[i].next)
      if ((nx = e[i].to) != p) dfs(nx, x, d + 1);
  }
  void init() {
    pw[0] = ipw[0] = 1;
    mod_t ibase = fpw(base, P - 2);
    for (int i = 1; i <= n; i++) pw[i] = pw[i - 1] * base;
    for (int i = 1; i <= n; i++) ipw[i] = ipw[i - 1] * ibase;
    dfs(1, 0, 0);
  }
  int qry(int x, int l, int lf, int y) {
    mod_t h1 = x[ha] - pw[x[dep] - l[dep]] * l[ha];
    mod_t h2 = (y[rha] - lf[rha]) * ipw[l[dep]];
    return (h1 + h2 * pw[x[dep] - l[dep]]).x;
  }
};
struct {
  int par[N], top[N], dep[N], sz[N], son[N];
  void dfs1(int x, int p, int d) {
    x[par] = p, x[dep] = d, x[sz] = 1;
    for (int i = x[head], nx, mx = 0; i; i = e[i].next)
      if ((nx = e[i].to) != p) {
        dfs1(nx, x, d + 1), x[sz] += nx[sz];
        if (nx[sz] > mx) mx = nx[sz], x[son] = nx;
      }
  }
  void dfs2(int x, int t) {
    x[top] = t;
    if (!x[son]) return;
    dfs2(x[son], t);
    for (int i = x[head], nx; i; i = e[i].next)
      if ((nx = e[i].to) != x[son] && nx != x[par]) dfs2(nx, nx);
  }
  void init(int rt = 1) { dfs1(rt, 0, rt), dfs2(rt, rt); }
  int operator()(int x, int y) {
    for (; x[top] != y[top]; x = x[top][par])
      if (x[top][dep] < y[top][dep]) std::swap(x, y);
    return x[dep] < y[dep] ? x : y;
  }
} LCA;
struct {
  int c, rt, p[N], dep[N], _dep[N], son[N], top[N], col[N], fa[N][LN];
  std::vector<int> up[N], down[N];
  void dfs1(int x, int _p, int d) {
    x[fa][0] = x[p] = _p, x[dep] = x[_dep] = d;
    for (int i = x[head], nx, mx = d; i; i = e[i].next)
      if ((nx = e[i].to) != _p) {
        dfs1(nx, x, d + 1), x[dep] = std::max(x[dep], nx[dep]);
        if (nx[dep] > mx) mx = nx[dep], x[son] = nx;
      }
  }
  void dfs2(int x, int t) {
    x[top] = t;
    if (!x[son]) return;
    dfs2(x[son], t);
    for (int i = x[head], nx; i; i = e[i].next)
      if ((nx = e[i].to) != x[son] && nx != x[p]) dfs2(nx, nx);
  }
  void init() {
    rt = 1;
    dfs1(rt, 0, 1), dfs2(rt, rt);
    for (int j = 1; j < LN; j++)
      for (int i = 1; i <= n; i++) i[fa][j] = i[fa][j - 1][fa][j - 1];
    for (int i = 1; i <= n; i++)
      if (i == i[top]) {
        c++, i[col] = c;
        for (int j = i; j[son]; j = j[son]) down[c].push_back(j);
        for (int j = i[p], l = down[c].size(); j && l--; j = j[p])
          up[c].push_back(j);
      }
  }
  int kth(int x, int k) {
    if (!k) return x;
    int high = log2(k);
    k -= 1 << high;
    x = x[fa][high];
    if (k <= x[_dep] - x[top][_dep])
      return x[top][col][down][x[_dep] - x[top][_dep] - k];
    else
      return x[top][col][up][k - x[_dep] + x[top][_dep] - 1];
  }
} qaq;
qwq<998244353, 100> mmp;
int m, x, y, z, w;
int main() {
  scanf("%d%s", &n, s + 1);
  for (int i = 1; i < n; i++) {
    x = read(), y = read();
    addedge(x, y);
  }
  mmp.init();
  LCA.init();
  qaq.init();
  for (int q = read(); "HgS /qq", q--;) {
    x = read(), y = read(), z = read(), w = read();
    int lxy = LCA(x, y), flxy = lxy[LCA.par];
    int lenxy = x[LCA.dep] + y[LCA.dep] - 2 * lxy[LCA.dep] + 1;
    int lzw = LCA(z, w), flzw = lzw[LCA.par];
    int lenzw = z[LCA.dep] + w[LCA.dep] - 2 * lzw[LCA.dep] + 1;
    int l = 1, r = std::min(lenxy, lenzw);
    if (s[x] != s[z]) {
      printf("%d\n", 0);
      continue;
    }
    while (l < r) {
      int xyval, zwval, tmp;
      if ((l + r + 1) / 2 <= x[LCA.dep] - lxy[LCA.dep]) {
        tmp = qaq.kth(x, (l + r + 1) / 2 - 1);
        xyval = mmp.qry(x, tmp, tmp[LCA.par], tmp);
      } else {
        tmp = qaq.kth(y, lenxy - (l + r + 1) / 2);
        xyval = mmp.qry(x, lxy, flxy, tmp);
      }
      if ((l + r + 1) / 2 <= z[LCA.dep] - lzw[LCA.dep]) {
        tmp = qaq.kth(z, (l + r + 1) / 2 - 1);
        zwval = mmp.qry(z, tmp, tmp[LCA.par], tmp);
      } else {
        tmp = qaq.kth(w, lenzw - (l + r + 1) / 2);
        zwval = mmp.qry(z, lzw, flzw, tmp);
      }
      if (xyval == zwval)
        l = (l + r + 1) / 2;
      else
        r = (l + r + 1) / 2 - 1;
    }
    printf("%d\n", l);
  }
}