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 unsigned mod = 3853518419u;
const unsigned base = 85429482u;
int n;
string s;
basic_string<int> e[300005];
int p[19][300005], du[300005];
unsigned bp[300005];
unsigned hu[19][300005], hd[19][300005];
void dfs(int x, int par) {
  p[0][x] = par;
  hu[0][x] = hd[0][x] = s[x];
  for (int i = 1; i < 19; i++) {
    int y = p[i - 1][x];
    p[i][x] = p[i - 1][y];
    hu[i][x] = (1ull * hu[i - 1][x] * bp[1 << (i - 1)] + hu[i - 1][y]) % mod;
    hd[i][x] = (1ull * hd[i - 1][y] * bp[1 << (i - 1)] + hd[i - 1][x]) % mod;
  }
  for (int y : e[x]) {
    if (y != par) {
      du[y] = du[x] + 1;
      dfs(y, x);
    }
  }
}
int dizi(int x, int k) {
  for (int i = 0; i < 19; i++) {
    if ((1 << i) & k) {
      x = p[i][x];
    }
  }
  return x;
}
int lca(int x, int y) {
  if (du[x] > du[y]) swap(x, y);
  y = dizi(y, du[y] - du[x]);
  if (x == y) return x;
  for (int i = 18; i >= 0; i--) {
    int xx = p[i][x], yy = p[i][y];
    if (xx != yy) {
      x = xx;
      y = yy;
    }
  }
  return p[0][x];
}
int resi(int a, int b, int c, int d) {
  int p = lca(a, b), q = lca(c, d), l = 0;
  int h = min(du[a] - du[p], du[c] - du[q]);
  for (int i = 18; i >= 0; i--) {
    if ((1 << i) <= h) {
      if (hu[i][a] == hu[i][c]) {
        l += 1 << i;
        h -= 1 << i;
        a = ::p[i][a];
        c = ::p[i][c];
      }
    }
  }
  if (h > 0) return l;
  if (a != p) {
    swap(a, c);
    swap(b, d);
    swap(p, q);
  }
  h = min(du[c] - du[q], du[b] - du[p]);
  for (int i = 18; i >= 0; i--) {
    if ((1 << i) <= h) {
      int t = dizi(b, du[b] - du[p] - (1 << i));
      if (hu[i][::p[0][t]] == hd[i][c]) {
        l += 1 << i;
        h -= 1 << i;
        p = t;
        c = ::p[i][c];
      }
    }
  }
  if (h > 0) return l;
  if (b == p) return l + (s[p] == s[c]);
  h = min(du[d] - du[q], du[b] - du[p]);
  for (int i = 18; i >= 0; i--) {
    if ((1 << i) <= h) {
      int t1 = dizi(b, du[b] - du[p] - (1 << i));
      int t2 = dizi(d, du[d] - du[q] - (1 << i));
      if (hu[i][::p[0][t1]] == hu[i][::p[0][t2]]) {
        l += 1 << i;
        h -= 1 << i;
        p = t1;
        q = t2;
      }
    }
  }
  if (h > 0) return l;
  return l + (s[p] == s[q]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cerr.tie(nullptr);
  cin >> n >> s;
  s = string(" ") + s;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    e[u] += v;
    e[v] += u;
  }
  bp[0] = 1;
  for (int i = 1; i < 300005; i++) bp[i] = bp[i - 1] * 1ull * base % mod;
  dfs(1, 1);
  int q;
  cin >> q;
  while (q--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << resi(a, b, c, d) << '\n';
  }
}