#include <bits/stdc++.h>
using namespace std;
const int inf = int(1e9);
const double eps = 1e-4;
const double pi = 4 * atan(double(1));
const int LOG = 19;
const int N = int(3e5) + 100;
const int M = int(1e6) + 100;
const int X = 4243;
const int MOD = int(1e9) + 7;
struct _hash {
  int a;
  _hash() {}
  _hash(int a) : a(a) {}
};
_hash operator+(const _hash &a, const _hash &b) {
  _hash c(a.a + b.a);
  if (c.a >= MOD) {
    c.a -= MOD;
  }
  return c;
}
_hash operator-(const _hash &a, const _hash &b) {
  _hash c(a.a - b.a);
  if (c.a < 0) {
    c.a += MOD;
  }
  return c;
}
_hash operator*(const _hash &a, const _hash &b) {
  return _hash((1LL * a.a * b.a) % MOD);
}
bool operator==(const _hash &a, const _hash &b) { return a.a == b.a; }
struct tq {
  int a, b, ab, c, d, cd;
};
int n, shift, sz;
bool used[N];
char s[N];
int _prev[N], _rank[N], val[N], h[N], p[N];
_hash pw[2 * N], sum[N], rev_sum[N];
int last_bit[10 * N];
vector<pair<int, int *> > lca[N];
tq q[M];
int *ptr[N][LOG];
int *cur[LOG];
vector<int> g[N];
int get(int a) {
  if (_prev[a] != a) {
    _prev[a] = get(_prev[a]);
  }
  return _prev[a];
}
inline void merge(int a, int b, int c) {
  a = get(a);
  b = get(b);
  if (_rank[a] < _rank[b]) {
    swap(a, b);
  }
  _prev[b] = a;
  if (_rank[a] == _rank[b]) {
    ++_rank[a];
  }
  val[a] = c;
}
void dfs(int v, int pv) {
  int *mem[LOG];
  for (int i = 0; i < LOG; ++i) {
    mem[i] = cur[i];
  }
  if ((sz & 1) == 0) {
    cur[0] = new int[1];
    cur[0][0] = v;
  } else {
    int ptr = 0;
    while (ptr + 1 < LOG && (sz & (1 << (ptr + 1))) != 0) {
      ++ptr;
    }
    cur[ptr + 1] = new int[(1 << (ptr + 1))];
    int p = 0;
    for (int i = ptr; i >= 0; --i) {
      for (int j = 0; j < (1 << i); ++j) {
        cur[ptr + 1][p++] = cur[i][j];
      }
      cur[i] = NULL;
    }
    cur[ptr + 1][p++] = v;
  }
  ++sz;
  for (int i = 0; i < LOG; ++i) {
    ptr[v][i] = cur[i];
  }
  used[v] = true;
  p[v] = pv;
  if (pv == -1) {
    h[v] = 0;
    sum[v] = pw[0] * _hash(s[v]);
    rev_sum[v] = pw[n] * _hash(s[v]);
  } else {
    g[v].erase(find((g[v]).begin(), (g[v]).end(), pv));
    h[v] = h[pv] + 1;
    sum[v] = sum[pv] + pw[h[v]] * _hash(s[v]);
    rev_sum[v] = rev_sum[pv] + pw[n - h[v]] * _hash(s[v]);
  }
  for (int i = 0; i < int((lca[v]).size()); ++i) {
    if (used[lca[v][i].first]) {
      *(lca[v][i].second) = val[get(lca[v][i].first)];
    }
  }
  for (int i = 0; i < int((g[v]).size()); ++i) {
    dfs(g[v][i], v);
    merge(v, g[v][i], v);
  }
  for (int i = 0; i < LOG; ++i) {
    cur[i] = mem[i];
  }
  --sz;
}
inline int len(int a, int b, int ab) { return h[a] + h[b] - 2 * h[ab] + 1; }
inline int get_ver(int v, int len) {
  int sz = h[v] + 1 + shift;
  int bit = last_bit[sz ^ (sz - len)];
  len -= (sz & ((1 << bit) - 1));
  return ptr[v][bit][(1 << bit) - len];
}
inline _hash get_rev_sum(int v, int pv) {
  return (rev_sum[v] - (p[pv] == -1 ? _hash(0) : rev_sum[p[pv]])) * pw[h[v]];
}
inline _hash get_hash(int a, int b, int ab, int len) {
  if (len <= h[a] - h[ab] + 1) {
    return get_rev_sum(a, get_ver(a, len));
  }
  len -= h[a] - h[ab] + 1;
  int push_back = get_ver(b, h[b] - h[ab]);
  return get_rev_sum(a, ab) +
         (sum[get_ver(b, h[b] - h[ab] - len + 1)] - sum[ab]) *
             pw[n + (h[a] - h[ab] + 1) - h[push_back]];
}
int main() {
  scanf("%d", &n);
  gets(s);
  gets(s);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  pw[0] = _hash(1);
  for (int i = 1; i <= 2 * n; ++i) {
    pw[i] = pw[i - 1] * X;
  }
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d %d %d %d", &q[i].a, &q[i].b, &q[i].c, &q[i].d);
    --q[i].a;
    --q[i].b;
    --q[i].c;
    --q[i].d;
    lca[q[i].a].push_back(make_pair(q[i].b, &q[i].ab));
    lca[q[i].b].push_back(make_pair(q[i].a, &q[i].ab));
    lca[q[i].c].push_back(make_pair(q[i].d, &q[i].cd));
    lca[q[i].d].push_back(make_pair(q[i].c, &q[i].cd));
  }
  for (int i = 0; i < n; ++i) {
    _prev[i] = i;
    _rank[i] = 1;
    val[i] = i;
  }
  for (int i = 0; i < LOG; ++i) {
    cur[i] = NULL;
  }
  sz = 0;
  shift = 0;
  for (int i = 0; i < shift; ++i) {
    if (sz == 0) {
      cur[0] = new int[1];
      cur[0][0] = -1;
    } else {
      if ((sz & 1) == 0) {
        cur[0] = new int[1];
        cur[0][0] = -1;
      } else {
        int ptr = 0;
        while (ptr + 1 < LOG && (sz & (1 << (ptr + 1))) != 0) {
          ++ptr;
        }
        cur[ptr + 1] = new int[(1 << (ptr + 1))];
        int p = 0;
        for (int j = ptr; j >= 0; --j) {
          for (int z = 0; z < (1 << j); ++z) {
            cur[ptr + 1][p++] = cur[j][z];
          }
          cur[j] = NULL;
        }
        cur[ptr + 1][p++] = -1;
      }
    }
    ++sz;
  }
  dfs(0, -1);
  for (int i = 1; i <= 2 * (n + shift) + 100; ++i) {
    for (int j = LOG - 1; j >= 0; --j) {
      if ((i & (1 << j)) != 0) {
        last_bit[i] = j;
        break;
      }
    }
  }
  for (int i = 0; i < m; ++i) {
    int ans = 0, l = 1,
        r = min(len(q[i].a, q[i].b, q[i].ab), len(q[i].c, q[i].d, q[i].cd));
    while (l <= r) {
      int mid = (l + r) / 2;
      _hash h1 = get_hash(q[i].a, q[i].b, q[i].ab, mid);
      _hash h2 = get_hash(q[i].c, q[i].d, q[i].cd, mid);
      if (h1 == h2) {
        ans = mid;
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
