#include <bits/stdc++.h>

using namespace std;

const int B = 650;
const int N = 300010;

vector <int> g[N];
tuple <int, int, int, int> queries[N];
int qu[N], qv[N], qlca[N], ql[N], qr[N], ans[N], good[N], goodSum[N];
int n, q, a[N], p[N], h[N], jump[N], flat[N << 1], in[N], out[N], ptr;

void go (int u = 1, int par = -1) {
  flat[++ptr] = u, in[u] = ptr;
  for (int v : g[u]) if (v ^ par) {
    p[v] = u, h[v] = h[u] + 1;
    int x = jump[u], y = jump[x];
    jump[v] = (h[u] + h[y] == h[x] + h[x]) ? y : u;
    go(v, u);
  }
  flat[++ptr] = u, out[u] = ptr;
}

int lca (int u, int v) {
  if (h[u] < h[v]) swap(u, v);
  while (h[u] > h[v]) u = h[jump[u]] < h[v] ? p[u] : jump[u];
  while (u ^ v) (jump[u] ^ jump[v]) ? (u = jump[u], v = jump[v]) : (u = p[u], v = p[v]);
  return u;
}

inline void add (int c) {
  good[c] ? --goodSum[c / B] : ++goodSum[c / B], good[c] ^= 1;
}

int query (int l, int r) {
  int lb = l / B, rb = r / B;
  if (lb == rb) {
    for (int i = l; i <= r; ++i) if (good[i]) return i;
    return -1;
  }
  int st = (lb + 1) * B, en = rb * B;
  for (int i = l; i < st; ++i) if (good[i]) return i;
  for (int i = en; i <= r; ++i) if (good[i]) return i;
  for (int blk = lb + 1; blk < rb; ++blk) if (goodSum[blk]) {
    for (int i = blk * B; i < blk * B + B; ++i) if (good[i]) return i;
  }
  return -1;
}

int main() {
  cin >> n >> q;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
  }
  for (int i = 1, u, v; i < n; ++i) {
    scanf("%d %d", &u, &v);
    g[u].emplace_back(v);
    g[v].emplace_back(u);
  }
  p[1] = -1, jump[1] = 1; go();
  for (int i = 1; i <= q; ++i) {
    int u, v, l, r;
    scanf("%d %d %d %d", &u, &v, &l, &r);
    if (in[u] > in[v]) swap(u, v);
    int root = lca(u, v);
    ql[i] = l, qr[i] = r, qu[i] = u, qv[i] = v, qlca[i] = root;
    if (u == root) queries[i] = make_tuple(in[u] / B, in[v], in[u], i);
    else queries[i] = make_tuple(out[u] / B, in[v], out[u], i);
  }
  for (int i = 1; i <= ptr; ++i) flat[i] = a[flat[i]];
  sort(queries + 1, queries + q + 1);
  int L = 1, R = 0;
  for (int i = 1; i <= q; ++i) {
    auto [blockID, rt, lt, idx] = queries[i];
    while (R < rt) add(flat[++R]);
    while (L > lt) add(flat[--L]);
    while (L < lt) add(flat[L++]);
    while (R > rt) add(flat[R--]);
    if (qlca[idx] != qu[idx]) add(flat[in[qlca[idx]]]);
    ans[idx] = query(ql[idx], qr[idx]);
    if (qlca[idx] != qu[idx]) add(flat[in[qlca[idx]]]);
  }
  for (int i = 1; i <= q; ++i) printf("%d\n", ans[i]);
  return 0;
}

