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;
template <class P, class Q>
inline void smin(P &a, Q b) {
  if (b < a) a = b;
}
template <class P, class Q>
inline void smax(P &a, Q b) {
  if (a < b) a = b;
}
const int maxn = 300000 + 100;
const int maxlg = 20;
const int base = 727;
const int mod = 1000000000 + 7;
long long pw[maxn];
long long pw2[maxn];
int n, m;
char s[maxn];
vector<int> adj[maxn];
int dep[maxn];
int par[maxn][maxlg];
long long up[maxn][maxlg], dw[maxn][maxlg];
int up2[maxn][maxlg], dw2[maxn][maxlg];
inline int nextInt() {
  register char ch;
  register int res;
  while ((ch = getchar()) < '0')
    ;
  for (res = ch - '0'; (ch = getchar()) >= '0'; res = res * 10 + ch - '0')
    ;
  return res;
}
void writen(register int Q) {
  static char W[12], E;
  W[11] = '\n';
  for (W[0xA] = Q % 0xA + 0x30, Q /= 0xA, E = 0xA; Q;
       W[(int)--E] = Q % 0xA + 0x30, Q /= 0xA)
    ;
  fwrite(W + E, 0x1, 0xC - E, stdout);
}
void dfs(int u, int parent, int depth) {
  dep[u] = depth;
  par[u][0] = parent;
  up[u][0] = dw[u][0] = s[u];
  up2[u][0] = dw2[u][0] = s[u];
  for (int i = (int)(1), _n = (int)(maxlg); i < _n; i++) {
    par[u][i] = par[par[u][i - 1]][i - 1];
    up[u][i] = up[u][i - 1] * pw[1 << (i - 1)] + up[par[u][i - 1]][i - 1];
    dw[u][i] = dw[par[u][i - 1]][i - 1] * pw[1 << (i - 1)] + dw[u][i - 1];
    up2[u][i] =
        (up2[u][i - 1] * pw2[1 << (i - 1)] + up2[par[u][i - 1]][i - 1]) % mod;
    dw2[u][i] =
        (dw2[par[u][i - 1]][i - 1] * pw2[1 << (i - 1)] + dw2[u][i - 1]) % mod;
  }
  for (int v : adj[u])
    if (v != parent) dfs(v, u, depth + 1);
}
int lca(int u, int v) {
  if (dep[u] > dep[v]) swap(u, v);
  for (int i = (int)(maxlg), _x = (int)(0); i-- > _x;)
    if (dep[par[v][i]] >= dep[u]) v = par[v][i];
  if (u == v) return u;
  for (int i = (int)(maxlg), _x = (int)(0); i-- > _x;)
    if (par[u][i] != par[v][i]) u = par[u][i], v = par[v][i];
  return par[u][0];
}
inline int depkpar(int u, int depth) {
  for (int i = (int)(maxlg), _x = (int)(0); i-- > _x;)
    if (dep[par[u][i]] >= depth) u = par[u][i];
  return u;
}
int solve(int a, int b, int c, int d) {
  int x = lca(a, b), y = lca(c, d);
  int ans = 0;
  for (int i = (int)(maxlg), _x = (int)(0); i-- > _x;)
    if ((1 << i) <= min(dep[a] - dep[x], dep[c] - dep[y]) + 1)
      if (up[a][i] == up[c][i] && up2[a][i] == up2[c][i])
        ans += 1 << i, a = par[a][i], c = par[c][i];
  if (dep[a] >= dep[x] && dep[c] >= dep[y]) return ans;
  if (dep[a] < dep[x]) swap(a, c), swap(b, d), swap(x, y);
  c = y;
  for (int i = (int)(maxlg), _x = (int)(0); i-- > _x;)
    if ((1 << i) <= dep[d] - dep[y] && (1 << i) <= dep[a] - dep[x] + 1) {
      int pd = depkpar(d, dep[y] + (1 << i));
      if (up[a][i] == dw[pd][i] && up2[a][i] == dw2[pd][i])
        ans += 1 << i, a = par[a][i], y = pd;
    }
  if (dep[a] >= dep[x] || (dep[a] < dep[x] && x == b) || y == d) return ans;
  a = x;
  for (int i = (int)(maxlg), _x = (int)(0); i-- > _x;)
    if ((1 << i) <= min(dep[b] - dep[x], dep[d] - dep[y])) {
      int push_back = depkpar(b, dep[x] + (1 << i));
      int pd = depkpar(d, dep[y] + (1 << i));
      if (dw[push_back][i] == dw[pd][i] && dw2[push_back][i] == dw2[pd][i])
        ans += 1 << i, x = push_back, y = pd;
    }
  return ans;
}
int main() {
  pw[0] = 1;
  for (int i = (int)(1), _n = (int)(maxn); i < _n; i++)
    pw[i] = pw[i - 1] * base;
  pw2[0] = 1;
  for (int i = (int)(1), _n = (int)(maxn); i < _n; i++)
    pw2[i] = pw2[i - 1] * base % mod;
  n = nextInt();
  scanf("%s", s);
  for (int i = 0, _n = (int)(n - 1); i < _n; i++) {
    int u, v;
    u = nextInt(), v = nextInt(), u--, v--;
    adj[u].push_back(v), adj[v].push_back(u);
  }
  adj[0].push_back(n), adj[n].push_back(0);
  dfs(n, n, 0);
  cin >> m;
  for (int z = 0, _n = (int)(m); z < _n; z++) {
    int a, b, c, d;
    a = nextInt(), b = nextInt(), c = nextInt(), d = nextInt();
    a--, b--, c--, d--;
    writen(solve(a, b, c, d));
  }
  return 0;
}