#include<bits/stdc++.h>
#define mid ((l+r)>>1)
using namespace std;
const int N = 2e5+5;
int a[N],tmp[N],root[N];
struct node{
int l,r;
int sum;
}tree[N<<5];
int tot = 0;
bool cmp(int x,int y){
return x < y;
}
int build(int l,int r){
int p = ++tot;
if(l == r){
return p;
}
tree[p].l = build(l,mid);
tree[p].r = build(mid+1,r);
return p;
}
int change(int now,int l,int r,int x){
int p = ++tot;
tree[p] = tree[now];
if(l == r){
tree[p].sum = 1;
return p;
}
if(x <= mid){
tree[p].l = change(tree[now].l,l,mid,x);
}else{
tree[p].r = change(tree[now].r,mid+1,r,x);
}
tree[p].sum = tree[tree[p].l].sum + tree[tree[p].r].sum;
return p;
}
int solve(int p1,int p2,int l,int r,int x){
if(l == r){
return r;
}
int t = tree[tree[p2].l].sum - tree[tree[p1].l].sum;
if(t >= x){
return solve(tree[p1].l,tree[p2].l,l,mid,x);
}else{
return solve(tree[p1].r,tree[p2].r,mid+1,r,x-t);
}
}
int main(){
int n,m;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
tmp[i] = a[i];
}
sort(tmp+1,tmp+1+n,cmp);
int t = unique(tmp+1,tmp+1+n) - tmp-1;
for(int i=1;i<=n;i++){
a[i] = upper_bound(tmp+1,tmp+1+t,a[i])-tmp-1;
}
root[0] = build(1,n);
for(int i=1;i<=n;i++){
root[i] = change(root[i-1],1,n,a[i]);
}
for(int i=1;i<=n;i++){
int l,r,x;
scanf("%d%d%d",&l,&r,&x);
printf("%d\n",tmp[solve(root[l-1],root[r],1,t,x)]);
}
}