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>
#pragma GCC optimize("Ofast")
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  char ch = getchar();
  long long f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f *= -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  x *= f;
}
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
const long long base1 = 233, base2 = 2333;
const long long MOD1 = 1e9 + 7, MOD2 = 1e9 + 9;
char s[300010];
int fa[300010];
int dep[300010];
int f[300010][20];
long long h1[300010][20], h2[300010][20];
long long h1_inv[300010][20], h2_inv[300010][20];
long long p1[300010], p2[300010];
vector<int> e[300010];
void pre(int);
void dfs(int);
int get_lca(int, int);
int getX(int, int, int);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  pre(300000);
  int n, m;
  int x, y;
  int a, b, c, d;
  cin >> n;
  cin >> s + 1;
  for (int i = 1; i < n; ++i) {
    cin >> x >> y;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  dfs(1);
  cin >> m;
  while (m--) {
    cin >> a >> b >> c >> d;
    int l1 = get_lca(a, b);
    int l2 = get_lca(c, d);
    if (s[a] != s[c]) {
      cout << 0 << '\n';
      continue;
    }
    int ans = 1;
    if (dep[a] - dep[l1] > dep[c] - dep[l2]) {
      swap(a, c);
      swap(b, d);
      swap(l1, l2);
    }
    for (int i = 19, len = 1 << i; i >= 0; --i, len >>= 1) {
      if (dep[a] - len < dep[l1]) continue;
      if (h1[a][i] == h1[c][i] && h2[a][i] == h2[c][i]) {
        ans += len;
        a = f[a][i];
        c = f[c][i];
      }
    }
    if (a != l1) {
      cout << ans << '\n';
      continue;
    }
    for (int i = 19, len = 1 << i; i >= 0; --i, len >>= 1) {
      if (dep[c] - len < dep[l2]) continue;
      if (dep[a] + len > dep[b]) continue;
      int x = getX(b, a, len);
      if (h1_inv[x][i] == h1[c][i] && h2_inv[x][i] == h2[c][i]) {
        ans += len;
        a = x;
        c = f[c][i];
      }
    }
    if (c != l2) {
      cout << ans << '\n';
      continue;
    }
    if (dep[b] - dep[a] > dep[d] - dep[c]) {
      swap(a, c);
      swap(b, d);
    }
    for (int i = 19, len = 1 << i; i >= 0; --i, len >>= 1) {
      if (dep[a] + len > dep[b]) continue;
      int x = getX(b, a, len);
      int y = getX(d, c, len);
      if (h1_inv[x][i] == h1_inv[y][i] && h2_inv[x][i] == h2_inv[y][i]) {
        ans += len;
        a = x;
        c = y;
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
void pre(int n) {
  p1[0] = p2[0] = 1;
  for (int i = 1; i <= n; ++i) {
    p1[i] = p1[i - 1] * base1 % MOD1;
    p2[i] = p2[i - 1] * base2 % MOD2;
  }
}
void dfs(int x) {
  dep[x] = dep[fa[x]] + 1;
  f[x][0] = fa[x];
  h1[x][0] = h2[x][0] = s[fa[x]];
  h1_inv[x][0] = h2_inv[x][0] = s[x];
  for (int i = 1, len = 1; i < 20; ++i, len <<= 1) {
    int tmp = f[x][i - 1];
    f[x][i] = f[tmp][i - 1];
    h1[x][i] = (h1[x][i - 1] * p1[len] + h1[tmp][i - 1]) % MOD1;
    h2[x][i] = (h2[x][i - 1] * p2[len] + h2[tmp][i - 1]) % MOD2;
    h1_inv[x][i] = (h1_inv[tmp][i - 1] * p1[len] + h1_inv[x][i - 1]) % MOD1;
    h2_inv[x][i] = (h2_inv[tmp][i - 1] * p2[len] + h2_inv[x][i - 1]) % MOD2;
  }
  for (auto v : e[x]) {
    if (v == fa[x]) continue;
    fa[v] = x;
    dfs(v);
  }
}
int get_lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 19, len = 1 << i; i >= 0; --i, len >>= 1) {
    if (dep[x] - len >= dep[y]) x = f[x][i];
  }
  if (x == y) return x;
  for (int i = 19; i >= 0; --i) {
    if (f[x][i] != f[y][i]) {
      x = f[x][i];
      y = f[y][i];
    }
  }
  return f[x][0];
}
int getX(int from, int to, int dis) {
  int del = dep[from] - dep[to] - dis;
  for (int i = 19, j = 1 << i; i >= 0; --i, j >>= 1) {
    if (j & del) from = f[from][i];
  }
  return from;
}