using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int(), Q = Reader.Int();
        var A = Reader.IntArray(N);
        var Sorted = new int[N];
        Array.Copy(A, Sorted, N);
        Array.Sort(Sorted);
        for (int i = 0; i < N; i++)
            A[i] = Array.BinarySearch(Sorted, A[i]);
        var hld = new HLDecomposition(A);
        for (int i = 0; i < N - 1; i++)
            hld.AddEdge(Reader.Int() - 1, Reader.Int() - 1);
        hld.Build();
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        foreach (var q in Reader.IntTable(Q))
            Console.WriteLine(Sorted[hld.Kthnumber(--q[0], --q[1], q[2])]);
        Console.Out.Flush();
        Console.ReadLine();
    }


    class HLDecomposition
    {
        public readonly int N;
        List<int>[] E;
        int[] Y, X, Size, Parent, Up, UnderL, UnderR;
        public List<List<int>> Path = new List<List<int>>();
        public List<int> PathDepth = new List<int>();

        int[] Val;
        KthSmallest[] kth;

        void Init()
        {
            kth = new KthSmallest[Path.Count];
            for (int p = 0; p < Path.Count; p++)
            {
                int[] v = new int[Path[p].Count];
                for (int i = 0; i < v.Length; i++)
                    v[i] = Val[Path[p][i]];
                kth[p] = new KthSmallest(v);
            }
        }

        public int Kthnumber(int A, int B, int K)
        {
            int lb = -1, ub = N - 1;
            while (ub - lb > 1)
            {
                int mid = (lb + ub) / 2;
                int count = 0;
                int a = A, b = B;
                for (int at = Y[a], L = 0, R, na = a, nb = b; a != -1; a = na, b = nb)
                {
                    if (Y[a] == Y[b]) { at = Y[a]; L = Math.Min(X[a], X[b]); R = Math.Max(X[a], X[b]); na = -1; }
                    else if (PathDepth[Y[a]] >= PathDepth[Y[b]]) { at = Y[a]; L = 0; R = X[a]; na = Up[a]; }
                    else { at = Y[b]; L = 0; R = X[b]; nb = Up[b]; }

                    count += kth[at].Rank(L, R + 1, mid);
                    if (count >= K) break;
                }
                if (count >= K) ub = mid;
                else lb = mid;
            }
            return ub;
        }


        public HLDecomposition(int[] val)
        {
            N = val.Length;
            this.Val = val;
            Y = new int[N]; X = new int[N];
            Size = new int[N]; Parent = new int[N]; Up = new int[N];
            UnderL = new int[N]; UnderR = new int[N];
            E = new List<int>[N];
            for (int i = 0; i < N; i++) E[i] = new List<int>();
        }
        public void AddEdge(int a, int b)
        {
            E[a].Add(b);
            E[b].Add(a);
        }
        public void Build(int root = 0)
        {
            CountNodes();
            CompressPath();
            Init();
        }
        void CountNodes()
        {
            var stack = new Stack<int>();
            var nodes = new int[N];
            int ni = N - 1;
            stack.Push(0);
            while (stack.Count > 0)
            {
                int a = stack.Pop();
                for (int ei = 0; ei < E[a].Count; ei++)
                {
                    int b = E[a][ei];
                    if (b == Parent[a]) { E[a].RemoveAt(ei); ei--; }
                    else { Parent[b] = a; stack.Push(b); }
                }
                nodes[ni--] = a;
            }
            foreach (int a in nodes)
            {
                Size[a] = 1;
                var e = E[a];
                for (int i = 0; i < e.Count; i++)
                {
                    int b = e[i];
                    Size[a] += Size[b];
                    if (Size[b] > Size[e[0]]) { int t = e[0]; e[0] = b; e[i] = t; }
                }
            }
        }
        void CompressPath()
        {
            var stack = new Stack<int>();
            stack.Push(0);
            while (stack.Count > 0)
            {
                int a = stack.Pop();
                if (a < 0) { UnderR[~a] = Path.Count; continue; }
                if (X[a] == 0)
                {
                    Path.Add(new List<int>());
                    PathDepth.Add(a == 0 ? 0 : PathDepth[Y[Parent[a]]] + 1);
                }
                int pathId = Y[a] = Path.Count - 1;
                Path[pathId].Add(a);
                Up[a] = Parent[Path[pathId][0]];
                UnderL[a] = Path.Count;
                stack.Push(~a);
                if (E[a].Count == 0) continue;
                for (int i = E[a].Count - 1; i > 0; i--)
                    stack.Push(E[a][i]);
                X[E[a][0]] = X[a] + 1;
                stack.Push(E[a][0]);
            }
        }

        public int LCA(int a, int b)
        {
            int pa = Y[a], pb = Y[b];
            if (pa == pb) return (X[a] < X[b]) ? a : b;
            if (PathDepth[pa] >= PathDepth[pb]) return LCA(Parent[Path[pa][0]], b);
            return LCA(a, Parent[Path[pb][0]]);
        }
    }


    class KthSmallest
    {
        int N;
        int[][] A;
        int[][] Left;
        int[] Sorted;

        public KthSmallest(int[] A)
        {
            N = A.Length;
            int logN = 1;
            while ((1 << logN) < N) logN++;
            this.A = new int[logN + 1][];
            Left = new int[logN + 1][];
            for (int depth = 0; depth <= logN; depth++)
            {
                this.A[depth] = new int[N];
                Left[depth] = new int[N];
            }
            var index = new int[N];
            for (int i = 0; i < N; i++) index[i] = i;
            Sorted = new int[N];
            Array.Copy(A, Sorted, N);
            Array.Sort(Sorted, index);
            for (int i = 0; i < N; i++) this.A[0][index[i]] = i;
            Init(0, N, 0);
        }

        void Init(int L, int R, int depth)
        {
            if (R - L <= 1) return;
            int mid = (L + R) >> 1, ai = L, bi = mid;
            for (int i = L; i < R; i++)
            {
                if (A[depth][i] < mid) A[depth + 1][ai++] = A[depth][i];
                else A[depth + 1][bi++] = A[depth][i];
                Left[depth][i] = ai - L;
            }
            Init(L, mid, depth + 1);
            Init(mid, R, depth + 1);
        }

        // K is 0-indexed
        public int KthNumber(int L, int R, int K)
        {
            int currL = 0, currR = N;
            K++;
            for (int depth = 0; currR - currL != 1; depth++)
            {
                int mid = (currL + currR) >> 1;
                int toL = Left[depth][R - 1];
                int outL = currL == L ? 0 : Left[depth][L - 1];
                int inL = toL - outL;
                if (inL >= K)
                {
                    L = currL + outL;
                    R = currL + toL;
                    currR = mid;
                }
                else
                {
                    L = mid + L - currL - outL;
                    R = mid + R - currL - toL;
                    K = K - inL;
                    currL = mid;
                }
            }
            return Sorted[currL];
        }

        // Count A[i] == val
        public int Count(int L, int R, int val)
        {
            return Rank(L, R, val) - Rank(L, R, val - 1);
        }

        // Count A[i] <= val
        public int Rank(int L, int R, int val)
        {
            int currL = 0, currR = N, res = 0;
            for (int depth = 0; L < R && currR - currL > 1; depth++)
            {
                int outL = currL == L ? 0 : Left[depth][L - 1];
                int inL = Left[depth][R - 1] - outL;
                int mid = (currL + currR) >> 1;
                if (val < Sorted[mid])
                {
                    L = currL + outL;
                    R = L + inL;
                    currR = mid;
                }
                else
                {
                    res += inL;
                    int inR = R - L - inL;
                    L = mid + L - currL - outL;
                    R = L + inR;
                    currL = mid;
                }
            }
            if (currR - currL == 1 && R - L == 1 && Sorted[L] <= val) res++;
            return res;
        }
    }
}

class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 71192