#include<bits/stdc++.h>
using namespace std;
const int M=4e5+4;
int n,q,a[M];
vector<int>tree[M],v;
#define all(v) v.begin(),v.end()
void build(int l,int r,int id)
{
if(l==r)
{
tree[id].push_back(a[l]);
return;
}
int m=(l+r)>>1;
build(l,m,2*id);
build(m+1,r,2*id+1);
merge(all(tree[2*id]),all(tree[2*id+1]),back_inserter(tree[id]));
}
int query(int l,int r,int id,int ql,int qr,int val)
{
if(r<ql || qr<l || ql>qr) return 0;
if(ql<=l && r<=qr)
return (int)(upper_bound(all(tree[id]),val-1)-tree[id].begin());
int m=(l+r)>>1;
return query(l,m,2*id,ql,qr,val)+query(m+1,r,2*id+1,ql,qr,val);
}
int main()
{
scanf("%d%d",&n,&q);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
v.push_back(a[i]);
}
sort(all(v));
for(int i=1;i<=n;i++) a[i]=lower_bound(all(v),a[i])-v.begin()+1;
build(1,n,1);
while(q--)
{
int l,r,k;
scanf("%d%d%d",&l,&r,&k);
int lo=1,hi=n,ans=-1;
while(lo<=hi)
{
int md=(lo+hi)>>1;
int vv=query(1,n,1,l,r,md);
if(k>vv) lo=md+1;
else if(k<vv) hi=md-1;
else
{
ans=md;
break;
}
}
printf("%d\n",v[ans-1]);
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY29uc3QgaW50IE09NGU1KzQ7CmludCBuLHEsYVtNXTsKdmVjdG9yPGludD50cmVlW01dLHY7CiNkZWZpbmUgYWxsKHYpIHYuYmVnaW4oKSx2LmVuZCgpCnZvaWQgYnVpbGQoaW50IGwsaW50IHIsaW50IGlkKQp7CglpZihsPT1yKQoJewoJCXRyZWVbaWRdLnB1c2hfYmFjayhhW2xdKTsKCQlyZXR1cm47Cgl9CglpbnQgbT0obCtyKT4+MTsKCWJ1aWxkKGwsbSwyKmlkKTsKCWJ1aWxkKG0rMSxyLDIqaWQrMSk7CgltZXJnZShhbGwodHJl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