#include <bits/stdc++.h>

using namespace std;

#ifdef NeverBeRed
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second

struct union_find
{
	vector<int> p;

	union_find(int n = 0) : p(n, -1) {}

	bool join(int u, int v)
	{
		if ((u = root(u)) == (v = root(v)))
			return false;
		if (p[u] > p[v])
			swap(u, v);
		p[u] += p[v];
		p[v] = u;
		return true;
	}

	int root(int u) { return p[u] < 0 ? u : p[u] = root(p[u]); }
};

int main()
{
	#ifdef TurnRed
		freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, q;
	cin >> n >> q;
	vector<int> a(n);
	for (auto &i : a) cin >> i, --i;

	vector<vector<int>> adj(n);
	for (int i = 1, u, v; i < n; ++i)
	{
		cin >> u >> v;
		--u, --v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	struct info { int u, v, l, r, lca, id; };
	vector<info> queries(q);
	for (auto &i : queries)
	{
		cin >> i.u >> i.v >> i.l >> i.r;
		--i.u, --i.v, --i.l, --i.r;
		i.id = &i - &queries[0];
	}

	vector<int> ancestor(n, -1);
	vector<vector<int>> who(n);
	union_find uf(n);
	for (auto &i : queries)
		who[i.u].push_back(&i-&queries[0]),
		who[i.v].push_back(&i-&queries[0]);

	vector<int> ft(n), ord;
	function<void(int)> dfs = [&](int u)
	{
		ord.push_back(a[u]);
		ancestor[u] = u;
		for (auto v : adj[u])
			if (ancestor[v] == -1)
			{
				dfs(v);
				uf.join(u, v);
				ancestor[uf.root(u)] = u;
			}
		for (auto i : who[u])
		{
			int v = (queries[i].u == u) ? queries[i].v : queries[i].u;
			if (ancestor[v] != -1)
				queries[i].lca = ancestor[uf.root(v)];
		}
		ft[u] = ord.size();
		ord.push_back(a[u]);
	};
	dfs(0);

	for (auto &i : queries)
	{
		i.u = ft[i.u], i.v = ft[i.v], i.lca = ft[i.lca];
		if (i.u > i.v) swap(i.u, i.v);
	}

	const int R = 280, R2 = 1000;
	sort(queries.begin(), queries.end(), [](info &x, info &y) -> bool
	{
		if (x.u / R2 != y.u / R2)
			return x.u / R2 < y.u / R2;
		return (x.v < y.v) ^ (x.u / R2 & 1);
	});

	vector<unsigned short> b(n / R + 1);
	vector<char> cur(n);

	auto upd = [&](int p)
	{
		p = ord[p];
		b[p / R] -= cur[p];
		cur[p] = !cur[p];
		b[p / R] += cur[p];
	};

	auto walk = [&](int l, int r, int &ans)
	{
		for (; l <= r; ++l)
			if (cur[l])
			{
				ans = l + 1;
				break;
			}
	};

	int l = 0, r = 0;
	vector<int> vans(q);
	for (auto &i : queries)
	{
		while (l < i.u) upd(l++);
		while (l > i.u) upd(--l);
		while (r < i.v) upd(r++);
		while (r > i.v) upd(--r);
		upd(i.lca);

		int bl = i.l / R, br = i.r / R, ans = -1;
		if (bl * R != i.l)
		{
			walk(i.l, min(i.r, ++bl * R - 1), ans);
			i.l = bl * R;
		}
		if (i.l <= i.r && i.r + 1 != (br + 1) * R)
			walk(br-- * R, i.r, ans);

		for (; bl <= br; ++bl)
			if (b[bl])
			{
				walk(bl * R, (bl + 1) * R, ans);
				break;
			}
		vans[i.id] = ans;
		upd(i.lca);
	}

	for (auto &i : vans)
		cout << i << "\n";

	return 0;
}
