#include<bits/stdc++.h>
using namespace std;
typedef long long int64;

struct SegmentTree
{
  int n;
  vector< vector< int > > data;
  SegmentTree(int sz)
  {
    n = 1;
    while(n < sz) n *= 2;
    data.resize(2 * n - 1);
  }
  void Build(vector< int >& d)
  {
    for(int i = 0; i < d.size(); i++) {
      data[i + n - 1].push_back(d[i]);
    }
    for(int i = n - 2; i >= 0; i--) {
      data[i].resize(data[2 * i + 1].size() + data[2 * i + 2].size());
      merge(data[2 * i + 1].begin(), data[2 * i + 1].end(), data[2 * i + 2].begin(), data[2 * i + 2].end(), data[i].begin());
    }
  }
  inline int Query(int a, int b, int x, int k, int l, int r)
  {
    if(a >= r || b <= l) return(0);
    if(a <= l && r <= b) return(upper_bound(data[k].begin(), data[k].end(), x) - data[k].begin());
    return(Query(a, b, x, 2 * k + 1, l, (l + r) >> 1) + Query(a, b, x, 2 * k + 2, (l + r) >> 1, r));
  }
  int Query(int a, int b, int x)
  {
    return(Query(a, b, x, 0, 0, n));
  }
};

struct CentroidPathDecomposition
{
  struct Centroid
  {
    int ParIndex, ParDepth, Deep;
    vector< int > node;
    inline int size()
    {
      return(node.size());
    }
    inline int &operator[](int k)
    {
      return(node[k]);
    }
    inline pair< int, int > Up()
    {
      return(make_pair(ParIndex, ParDepth));
    }
  };

  vector< vector< int > > graph;
  vector< int > SubTreeSize, NextPath;
  vector< int > TreeIndex, TreeDepth;
 vector< Centroid > Centroids;

  void BuildSubTreeSize()
  {
    stack< pair< int, int > > s;
    s.push({0, -1});
    while(!s.empty()) {
      auto p = s.top(); s.pop();
      if(~SubTreeSize[p.first]) {
        NextPath[p.first] = 0;
        for(auto& to : graph[p.first]) {
          SubTreeSize[p.first] += SubTreeSize[to];
          if(SubTreeSize[NextPath[p.first]] < SubTreeSize[to]) {
            NextPath[p.first] = to;
          }
        }
      } else {
        s.push(p);
        SubTreeSize[p.first] = 1;
        for(auto& to : graph[p.first]) {
          if(p.second != to) s.push({to, p.first});
        }
      }
    }
  }
  void BuildPath()
  {
    stack< pair< int, int > > s;
    Centroids.push_back((Centroid){-1, -1, 0});
    s.push({0, -1});
    TreeIndex[0] = 0;
    while(!s.empty()) {
      auto p = s.top(); s.pop();
      TreeDepth[p.first] = Centroids[TreeIndex[p.first]].size();
      for(auto& to : graph[p.first]) {
        if(p.second != to) {
          if(to == NextPath[p.first]) { // Centroid-Path
            TreeIndex[to] = TreeIndex[p.first];
          } else {                  // Not Centroid-Path
            TreeIndex[to] = Centroids.size();
            Centroids.push_back((Centroid){TreeIndex[p.first], TreeDepth[p.first], Centroids[TreeIndex[p.first]].Deep + 1});
          }
          s.push({to, p.first});
        }
      }
      Centroids[TreeIndex[p.first]].node.push_back(p.first);
    }
  }
  void AddEdge(int x, int y)
  {
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  void Build()
  {
    BuildSubTreeSize();
    BuildPath();
  }

  inline int size()
  {
    return(Centroids.size());
  }
  inline pair< int, int > Information(int idx)
  {
    return(make_pair(TreeIndex[idx], TreeDepth[idx]));
  }
  inline Centroid &operator[](int k)
  {
    return(Centroids[k]);
  }

  CentroidPathDecomposition(int SZ)
  {
    graph.resize(SZ);
    SubTreeSize.assign(SZ, -1);
    NextPath.resize(SZ);
    TreeIndex.resize(SZ);
    TreeDepth.resize(SZ);
  }
};

int main()
{
  int N, Q, x[100000];
  vector< int > nums;
  scanf("%d %d", &N, &Q);
  CentroidPathDecomposition CPD(N);
  for(int i = 0; i < N; i++) {
    scanf("%d", &x[i]);
    nums.push_back(x[i]);
  }
  sort(nums.begin(), nums.end());
  nums.erase(unique(nums.begin(), nums.end()), nums.end());
  for(int i = 0; i < N; i++) {
    x[i] = lower_bound(nums.begin(), nums.end(), x[i]) - nums.begin();
  }
  
  for(int i = 0; i < N - 1; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    CPD.AddEdge(--a, --b);
  }
  CPD.Build();
  vector< SegmentTree > segs;
  for(int i = 0; i < CPD.size(); i++) {
    segs.push_back(SegmentTree(CPD[i].size()));
    vector< int > data(CPD[i].size());
    for(int j = 0; j < CPD[i].size(); j++) data[j] = x[CPD[i][j]];
    segs[i].Build(data);
  }
  for(int i = 0; i < Q; i++) { // O(Q log^3 N)
    int v, w, l;
    scanf("%d %d %d", &v, &w, &l);
    --v, --w;
    int low = 0, high = N - 1;
    while(high - low > 0) {
      int mid = (high + low) >> 1;

      int Sum = 0;
      int TreeIdxA, TreeDepthA, TreeIdxB, TreeDepthB;
      tie(TreeIdxA, TreeDepthA) = CPD.Information(v);
      tie(TreeIdxB, TreeDepthB) = CPD.Information(w);
      while(TreeIdxA != TreeIdxB && Sum < l) {
        if(CPD[TreeIdxA].Deep > CPD[TreeIdxB].Deep) {
          Sum += segs[TreeIdxA].Query(0, TreeDepthA + 1, mid);
          tie(TreeIdxA, TreeDepthA) = CPD[TreeIdxA].Up();
        } else {
          Sum += segs[TreeIdxB].Query(0, TreeDepthB + 1, mid);
          tie(TreeIdxB, TreeDepthB) = CPD[TreeIdxB].Up();
        }
      }
      if(Sum < l) {
        if(TreeDepthA > TreeDepthB) swap(TreeDepthA, TreeDepthB);
        Sum += segs[TreeIdxA].Query(TreeDepthA, TreeDepthB + 1, mid);
      }
      if(Sum >= l) high = mid;
      else low = mid + 1;
    }
    printf("%d\n", nums[low]);
  }
}

Measured memory_bytes: 29404