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 uint64_t mod = (1ull << 61) - 1;
const unsigned long long bas = 31;
inline uint64_t mult(uint64_t a, uint64_t b) {
  uint64_t l1 = (uint32_t)a, h1 = a >> 32, l2 = (uint32_t)b, h2 = b >> 32;
  uint64_t l = l1 * l2, m = l1 * h2 + l2 * h1, h = h1 * h2;
  uint64_t ret =
      (l & mod) + (l >> 61) + (h << 3) + (m >> 29) + (m << 35 >> 3) + 1;
  ret = (ret & mod) + (ret >> 61);
  ret = (ret & mod) + (ret >> 61);
  return ret - 1;
}
inline unsigned long long add(unsigned long long a, unsigned long long b) {
  if ((a += b) >= mod) a -= mod;
  return a;
}
inline unsigned long long dec(unsigned long long a, unsigned long long b) {
  return add(a, mod - b);
}
const int maxn = 300010;
int n, m, siz[maxn], dfn[maxn], ch[maxn], fa[maxn], tim, top[maxn], dep[maxn],
    id[maxn];
char c[maxn];
unsigned long long hs[maxn], ihs[maxn], pw[maxn];
vector<int> v[maxn];
void dfs(int np, int fath) {
  siz[np] = 1;
  dep[np] = dep[fath] + 1;
  fa[np] = fath;
  for (int &x : v[np]) {
    if (x == fath) continue;
    dfs(x, np);
    siz[np] += siz[x];
    if (!ch[np] || siz[ch[np]] < siz[x]) ch[np] = x;
  }
}
void dfs2(int np, int tp) {
  dfn[np] = ++tim;
  top[np] = tp;
  id[tim] = np;
  if (ch[np]) dfs2(ch[np], tp);
  for (int &x : v[np]) {
    if (x == fa[np] || x == ch[np]) continue;
    dfs2(x, x);
  }
}
void getsection(int x, int y, vector<pair<int, int> > &ret) {
  vector<pair<int, int> > v1, v2;
  while (top[x] != top[y]) {
    if (dep[top[x]] > dep[top[y]]) {
      v1.push_back(make_pair(dfn[x], dfn[top[x]]));
      x = fa[top[x]];
    } else {
      v2.push_back(make_pair(dfn[top[y]], dfn[y]));
      y = fa[top[y]];
    }
  }
  v1.push_back(make_pair(dfn[x], dfn[y]));
  ret = v1;
  reverse(v2.begin(), v2.end());
  ret.insert(ret.end(), v2.begin(), v2.end());
}
inline unsigned long long gethashg(int l, int r, bool rev) {
  if (!rev) return dec(hs[r], mult(hs[l - 1], pw[r - l + 1]));
  return dec(ihs[l], mult(ihs[r + 1], pw[r - l + 1]));
}
inline unsigned long long gethash(int l, int r, int len) {
  if (l > r)
    return gethashg(l - len + 1, l, 1);
  else
    return gethashg(l, l + len - 1, 0);
}
int main() {
  scanf("%d%s", &n, c + 1);
  pw[0] = 1;
  for (int i = 1; i <= n; i++) pw[i] = mult(pw[i - 1], bas);
  for (int i = 1, ti, tj; i < n; i++) {
    scanf("%d%d", &ti, &tj);
    v[ti].push_back(tj);
    v[tj].push_back(ti);
  }
  dfs(1, 0);
  dfs2(1, 1);
  for (int i = 1; i <= n; i++)
    hs[i] = add(mult(hs[i - 1], bas), c[id[i]] - 'a' + 1);
  for (int i = n; i >= 1; i--)
    ihs[i] = add(mult(ihs[i + 1], bas), c[id[i]] - 'a' + 1);
  scanf("%d", &m);
  while (m--) {
    int p, q, r, s;
    scanf("%d%d%d%d", &p, &q, &r, &s);
    vector<pair<int, int> > p1, p2;
    getsection(p, q, p1);
    getsection(r, s, p2);
    int clen = 0, i = 0, j = 0;
    while (1) {
      if (i == p1.size() || j == p2.size()) {
        printf("%d\n", clen);
        break;
      }
      int l1 = abs(p1[i].second - p1[i].first) + 1,
          l2 = abs(p2[j].second - p2[j].first) + 1;
      int mxlen = min(l1, l2);
      if (gethash(p1[i].first, p1[i].second, mxlen) !=
          gethash(p2[j].first, p2[j].second, mxlen)) {
        int l = 1, r = mxlen - 1, ret = 0;
        while (l <= r) {
          int mid = (l + r) >> 1;
          if (gethash(p1[i].first, p1[i].second, mid) ==
              gethash(p2[j].first, p2[j].second, mid))
            ret = mid, l = mid + 1;
          else
            r = mid - 1;
        }
        printf("%d\n", clen + ret);
        break;
      }
      if (p1[i].first < p1[i].second) {
        p1[i].first += mxlen;
        if (p1[i].first > p1[i].second) i++;
      } else {
        p1[i].first -= mxlen;
        if (p1[i].first < p1[i].second) i++;
      }
      if (p2[j].first < p2[j].second) {
        p2[j].first += mxlen;
        if (p2[j].first > p2[j].second) j++;
      } else {
        p2[j].first -= mxlen;
        if (p2[j].first < p2[j].second) j++;
      }
      clen += mxlen;
    }
  }
  return 0;
}