using System;
using System.Linq;
using System.Linq.Expressions;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
//using System.Numerics;
//using Point = System.Numerics.Complex;
using Number = System.Int32;
namespace Program
{
    public class Solver
    {
        public void Solve()
        {
            var n = sc.Integer();
            var m = sc.Integer();
            var a = sc.Integer(n);
            var xs = a.Distinct().ToList(); xs.Sort();
            FenwickTree seq;
            seq = new FenwickTree(xs.Count);
            for (int i = 0; i < n; i++)
                a[i] = xs.BinarySearch(a[i]);
            var T = new EulerTourTreeGraph(n);
            var G = Enumerate(n, x => new List<int>());
            for (int i = 0; i < n - 1; i++)
            {
                var f = sc.Integer() - 1;
                var t = sc.Integer() - 1;
                T.AddEdge(f, t);
                G[f].Add(t);
                G[t].Add(f);
            }
            var GG = Enumerate(n, x => G[x].ToArray());
            T.Build(0);
            var Q = Enumerate(n, x => new List<int>());
            var K = new int[m];
            var L = new int[m];
            var R = new int[m];
            for (int i = 0; i < m; i++)
            {
                var f = sc.Integer() - 1;
                var t = sc.Integer() - 1;
                var k = sc.Integer();
                var lca = T.GetLCA(f, t);
                Q[f].Add(i);
                Q[t].Add(i);
                Q[lca].Add(m + i);

                K[i] = k;
                L[i] = -1;
                R[i] = xs.Count - 1;
            }
            var QQ = Enumerate(n, x => Q[x].ToArray());
            var M = new int[m];
            var V = new int[m];


            Action<int, int> dfs = null;
            dfs = (prev, cur) =>
              {
                  seq.Add(a[cur] + 1, 1);
                  foreach (var q in QQ[cur])
                      if (q < m)
                          V[q] += seq[M[q] + 1];
                      else
                      {
                          V[q - m] -= 2 * seq[M[q - m] + 1];
                          if (a[cur] <= M[q - m])
                              V[q - m]++;
                      }
                  foreach (var to in GG[cur])
                      if (to != prev) dfs(cur, to);
                  seq.Add(a[cur] + 1, -1);
              };
            for (int _ = 0; _ < 17; _++)
            {
                for (int i = 0; i < m; i++)
                    M[i] = (L[i] + R[i]) / 2;
                dfs(-1, 0);
                for (int i = 0; i < m; i++)
                {
                    if (V[i] >= K[i]) R[i] = M[i];
                    else L[i] = M[i];
                    V[i] = 0;
                }

            }
            for (int i = 0; i < m; i++)
                IO.Printer.Out.WriteLine(xs[R[i]]);

        }

        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }
        static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
    }
}
#region main
static class Ex
{
    //static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    //static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion
#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer: StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, T[] source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, T[] source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        public readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) return 0;
            if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; }

        public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        public string ScanLine()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b != '\n'; b = (char)read())
                if (b == 0) break;
                else if (b != '\r') sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != 0 && b != '-' && (b < '0' || '9' < b));
            if (b == 0) return long.MinValue;
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { var s = Scan(); return s != "" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN; }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
#endregion
#region Treegraph
public class EulerTourTreeGraph
{
    public int n;
    public List<int>[] G;
    /// <summary>
    /// ???
    /// </summary>
    public int[] par;
    /// <summary>
    /// ??±???
    /// </summary>
    public int[] d;
    /// <summary>
    /// ?????????????????¢??????i???????????????????????????
    /// </summary>
    public int[] ord;
    /// <summary>
    /// ?????? i ?????????????¨?????????¨???
    /// </summary>
    public int[] ordl;
    /// <summary>
    /// ?????? i ??????????????¨???
    /// </summary>
    public int[] ordr;
    public EulerTourTreeGraph(int N)
    {
        n = N;
        G = new List<int>[N];
        for (int i = 0; i < N; i++)
            G[i] = new List<int>();
        par = new int[N];
        d = new int[N];
        ord = new int[2 * N - 1];
        ordl = new int[N];
        ordr = new int[N];
    }
    public void AddEdge(int f, int t)
    {
        G[f].Add(t);
        G[t].Add(f);
    }
    void Walk(int root)
    {
        var stack = new FastStack<int>(n + 1);
        var iter = new int[n];
        stack.Push(root);
        par[root] = -1;
        d[root] = 0;
        var ptr = 0;

        while (stack.Any())
        {
            var p = stack.Peek();
            ord[ptr] = p;
            ptr++;
            if (iter[p] < G[p].Count && G[p][iter[p]] == par[p]) iter[p]++;
            if (iter[p] == G[p].Count)
            {
                stack.Pop();
                ordr[p] = ptr;
            }
            else
            {
                var to = G[p][iter[p]];
                iter[p]++;
                stack.Push(to);
                par[to] = p;
                d[to] = d[p] + 1;
                ordl[to] = ptr;
            }
        }
    }
    sparseTable rmq;
    void BuildLCA()
    {
        var dep = new int[2 * n - 1];
        for (int i = 0; i < 2 * n - 1; i++)
            dep[i] = d[ord[i]];
        rmq = new sparseTable(dep);
    }
    public void Build(int root)
    {
        Walk(root);
        BuildLCA();
    }

    public int GetLCA(int u, int v)
    {
        //ordl: u<v
        if (ordl[u] > ordl[v]) { var tmp = u; u = v; v = tmp; }
        return ord[rmq.Query(ordl[u], ordl[v])];
    }

    /// <summary>
    /// ??¨???????´???????LCA????????£?????????
    /// </summary>
    static public EulerTourTreeGraph Compress(int[] v, EulerTourTreeGraph G, List<int> ord = null)
    {
        if (ord == null) ord = new List<int>();
        for (int i = 0; i < v.Length; i++)
            ord.Add(G.ordl[v[i]]);
        ord.Sort();
        for (int i = 0; i < v.Length - 1; i++)
            ord.Add(G.ordl[G.GetLCA(G.ord[ord[i]], G.ord[ord[i + 1]])]);

        {
            var next = new List<int>(ord);
            next.Sort();
            ord.Clear();
            var prev = -114514;
            for (int i = 0; i < next.Count; i++)
            {
                if (next[i] == prev) continue;
                ord.Add(next[i]);
                prev = next[i];
            }
        }
        var n = ord.Count;
        var ret = new EulerTourTreeGraph(n);
        var stack = new FastStack<int>(n + 1);
        stack.Push(0);
        var ptr = 1;
        while (ptr < n)
        {
            var cur = stack.Peek();
            var a = G.ord[ord[cur]];
            if (G.ordr[a] > ord[ptr])
            {
                ret.AddEdge(cur, ptr);
                stack.Push(ptr++);
            }
            else stack.Pop();
        }

        return ret;
    }

    #region SparseTable
    class sparseTable
    {
        int n;
        int[] A;
        int[] id;
        public sparseTable(int[] a)
        {
            var k = 1;
            n = a.Length;
            for (int i = 1; i < n; i <<= 1) k++;
            A = a;
            id = new int[n * k];
            for (int i = 0; i < n; i++)
                id[i] = i;
            var d = 0;
            for (int i = 1; i < n; i <<= 1)
            {
                for (int j = 0; j < n; j++)
                    id[d + n + j] = id[d + j];
                d += n;
                for (int j = 0; j < n - i; j++)
                    if (A[id[d + j]] > A[id[d + j + i]]) id[d + j] = id[d + j + i];
            }
        }
        /// <summary>
        /// value of [l,r)
        /// </summary>
        public int Query(int l, int r)
        {
            int z = r - l, k = 0, e = 1, s;
            s = ((z & 0xffff0000) != 0 ? 1 : 0) << 4; z >>= s; e <<= s; k |= s;
            s = ((z & 0x0000ff00) != 0 ? 1 : 0) << 3; z >>= s; e <<= s; k |= s;
            s = ((z & 0x000000f0) != 0 ? 1 : 0) << 2; z >>= s; e <<= s; k |= s;
            s = ((z & 0x0000000c) != 0 ? 1 : 0) << 1; z >>= s; e <<= s; k |= s;
            s = ((z & 0x00000002) != 0 ? 1 : 0) << 0; z >>= s; e <<= s; k |= s;
            var x = id[l + n * k];
            var y = id[r - e + 1 + (n * k)];

            if (A[x] <= A[y])
                return x;
            else return y;
        }
    }
    #endregion
}
#endregion

#region FenwickTree
public class FenwickTree
{
    int n;
    Number[] bit;
    int max = 1;
    public FenwickTree(int size)
    {
        n = size; bit = new Number[n + 1];
        while ((max << 1) <= n) max <<= 1;
    }
    /// <summary>sum[a,b]</summary>
    public Number this[int i, int j] { get { return this[j] - this[i - 1]; } }
    /// <summary>sum[0,i]</summary>
    public Number this[int i] { get { Number s = 0; for (; i > 0; i -= i & -i) s += bit[i]; return s; } }
    public int LowerBound(Number w)
    {
        if (w <= 0) return 0;
        int x = 0;
        for (int k = max; k > 0; k >>= 1)
            if (x + k <= n && bit[x + k] < w)
            {
                w -= bit[x + k];
                x += k;
            }
        return x + 1;
    }
    /// <summary>add v to bit[i]</summary>
    public void Add(int i, Number v)
    {
        if (i == 0) System.Diagnostics.Debug.Fail("BIT is 1 indexed");
        for (; i <= n; i += i & -i) bit[i] += v;
    }
    public Number[] Items
    {
        get
        {
            var ret = new Number[n];
            for (int i = 0; i < n; i++)
                ret[i] = this[i + 1, i + 1];
            return ret;
        }
    }
}
#endregion
#region Stack<T>
public class FastStack<T>
{
    T[] data;
    int ptr;
    public FastStack(int size) { data = new T[size]; }
    public void Push(T item) { data[ptr++] = item; }
    public T Pop() { return data[--ptr]; }
    public T Peek() { return data[ptr - 1]; }
    public bool Any() { return ptr != 0; }
    public T Last { get { return data[ptr - 1]; } set { data[ptr - 1] = value; } }
    public int Count { get { return ptr; } }
}
#endregion


Measured memory_bytes: 79132