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 Base = 27;
const int Max = 300005;
const int Mod = 998244353;
const int inf = 0x3f3f3f3f;
char s[Max];
vector<int> g[Max], _v;
long long Hash[Max][3], Der[Max];
int n, m, t, ch = 1, a, b, c, d, Q;
int child[Max], cmo[Max], mal[Max], in[Max], L[Max], Pahan[Max], chn[Max],
    chb[Max], F[Max << 1][22];
long long mod(long long x) { return (x + Mod) % Mod; }
int mun(int x, int y) {
  if (L[x] < L[y]) return x;
  return y;
}
void Dfs(int v, int p) {
  _v.push_back(v);
  in[v] = (int)_v.size();
  child[v] = 1;
  Pahan[v] = p;
  L[v] = L[p] + 1;
  for (auto i : g[v]) {
    if (i == p) continue;
    Dfs(i, v);
    child[v] += child[i];
    _v.push_back(v);
  }
}
void Hld(int v, int p) {
  t++;
  cmo[t] = v;
  mal[v] = t;
  chn[v] = ch;
  int mx = 0, yr = -1;
  for (auto i : g[v]) {
    if (mx < child[i] && i != p) mx = child[i], yr = i;
  }
  if (~yr) Hld(yr, v);
  for (auto i : g[v])
    if (i != p && i != yr) ch++, chb[ch] = i, Hld(i, v);
}
void Build_Hash() {
  for (int i = 1; i <= n; i++)
    Hash[i][1] = mod(mod(Hash[i - 1][1] * Base) + (s[cmo[i]] - 'a' + 1));
  for (int i = n; i >= 1; i--)
    Hash[i][2] = mod(mod(Hash[i + 1][2] * Base) + (s[cmo[i]] - 'a' + 1));
}
void Build_Lca() {
  for (int i = 1; i <= (int)_v.size(); i++) F[i][0] = _v[i - 1];
  for (int j = 0; j < 20; j++)
    for (int i = 1; i + (1 << j) - 1 <= (int)_v.size(); i++)
      F[i][j + 1] = mun(F[i][j], F[i + (1 << j)][j]);
}
int Lca(int x, int y) {
  x = in[x];
  y = in[y];
  if (x > y) swap(x, y);
  int lg = log2(y - x + 1);
  return mun(F[x][lg], F[y - (1 << lg) + 1][lg]);
}
long long Tap(int l, int r, int x) {
  if (x == 1) return mod(Hash[r][1] - mod(Hash[l - 1][1] * Der[r - l + 1]));
  if (x == 2) return mod(Hash[l][2] - mod(Hash[r + 1][2] * Der[r - l + 1]));
}
long long AL(int x, int y, int lca, int z) {
  int al = 0;
  long long bosh = 0;
  while (1) {
    if (L[x] - L[chb[chn[x]]] + 1 >= z && L[x] - L[lca] + 1 >= z) {
      bosh = mod(bosh + mod(Der[al] * Tap(mal[x] - z + 1, mal[x], 1)));
      z = 0;
      break;
    }
    if (chn[x] == chn[lca]) {
      bosh = mod(bosh + mod(Der[al] * Tap(mal[lca], mal[x], 1)));
      al += L[x] - L[lca] + 1;
      z -= L[x] - L[lca] + 1;
      break;
    }
    bosh = mod(bosh + mod(Der[al] * Tap(mal[chb[chn[x]]], mal[x], 1)));
    z -= L[x] - L[chb[chn[x]]] + 1;
    al += L[x] - L[chb[chn[x]]] + 1;
    x = Pahan[chb[chn[x]]];
  }
  if (z) {
    int foo = (L[y] - L[lca] + 1) - z;
    while (1) {
      if (L[y] - L[chb[chn[y]]] + 1 >= foo) {
        y = cmo[mal[y] - foo + 1];
        break;
      }
      foo -= L[y] - L[chb[chn[y]]] + 1;
      y = Pahan[chb[chn[y]]];
    }
    while (1) {
      if (chn[y] == chn[lca]) {
        if (lca != y)
          bosh = mod(bosh + mod(Der[al] * Tap(mal[lca] + 1, mal[y], 2)));
        break;
      }
      bosh = mod(bosh + mod(Der[al + L[chb[chn[y]]] - L[lca] - 1] *
                            Tap(mal[chb[chn[y]]], mal[y], 2)));
      y = Pahan[chb[chn[y]]];
    }
  }
  return bosh;
}
int main() {
  scanf("%d%s", &n, s + 1);
  Der[0] = 1;
  for (int i = 1; i <= n; i++) Der[i] = mod(Der[i - 1] * Base);
  for (int i = 2; i <= n; i++) {
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  chb[1] = 1;
  Dfs(1, 0);
  Hld(1, 0);
  Build_Hash();
  Build_Lca();
  scanf("%d", &Q);
  for (int i = 1; i <= Q; i++) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int bir = Lca(a, b);
    int iki = Lca(c, d);
    int dis = min(L[a] + L[b] - 2 * L[bir], L[c] + L[d] - 2 * L[iki]) + 1;
    int res = 0;
    for (int j = 20; j >= 0; j--)
      if (res + (1 << j) <= dis &&
          AL(a, b, bir, res + (1 << j)) == AL(c, d, iki, res + (1 << j)))
        res += 1 << j;
    printf("%d\n", res);
  }
}