#include<cstdio> #include<algorithm> #include<cstring> #define N 100005 #define M N*20 using namespace std; int n,m,Q,a[N],b[N],rt[N],pool; int read() { int ret=0,neg=1;char j=getchar(); for (;j>‘9‘ || j<‘0‘;j=getchar()) if (j==‘-‘) neg=-1; for (;j>=‘0‘ && j<=‘9‘;j=getchar()) ret=ret*10+j-‘0‘; return ret*neg; } struct node { int lc,rc,sum; }t[M]; void disc_init() { sort(b+1,b+m+1); m=unique(b+1,b+m+1)-b-1; for (int i=1;i<=n;i++) a[i]=lower_bound(b+1,b+m+1,a[i])-b; } void Insert(const int &y,int &x,const int &l,const int &r,const int &p) { t[x=++pool]=t[y]; ++t[x].sum; if (l==r) return; int mid=l+r>>1; if (p<=mid) Insert(t[y].lc,t[x].lc,l,mid,p); else Insert(t[y].rc,t[x].rc,mid+1,r,p); } int Query(const int &nl,const int &nr,const int &l,const int &r,const int &k) { if (l==r) return l; int delta=t[t[nr].lc].sum-t[t[nl].lc].sum,mid=l+r>>1; if (delta>=k) return Query(t[nl].lc,t[nr].lc,l,mid,k); else return Query(t[nl].rc,t[nr].rc,mid+1,r,k-delta); } void tree_init() { for (int i=1;i<=n;i++) Insert(rt[i-1],rt[i],1,m,a[i]); } int main() { n=read(),Q=read(); for (int i=1;i<=n;i++) a[i]=b[++m]=read(); disc_init(); tree_init(); for (int i=1;i<=Q;i++) { int l=read(),r=read(),k=read(); printf("%d\n",b[Query(rt[l-1],rt[r],1,m,k)]); } return 0; }