#include <bits/stdc++.h>

using namespace std;

#define maxn 100100
#define gc getchar_unlocked

void scanint(int &x)
{
    register int c = gc();
    x = 0;
    bool neg=false;
    if(c=='-')
        neg=true;
    for(;(c<48 || c>57);c = gc());
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg)
        x=-x;
}

struct node{
    int cnt;
    node *left;
    node *right;
    node(){
        this->cnt=0;
        this->left=this;
        this->right=this;
    }
    node(int cnt, node *left, node *right):cnt(cnt), left(left), right(right){}
    node *insert(int L, int R, int val);
};

node *null;
node *tree[maxn];

node *node::insert(int L, int R, int val)
{
    if(L==R)
        return new node(this->cnt+1, null, null); //insert no. in node
    else{
        int mid = (L+R)>>1;
        if(val<=mid) //val lies in left child, update left
            return new node(this->cnt+1, this->left->insert(L, mid, val), this->right);
        else // val lies in right child, update right
            return new node(this->cnt+1, this->left, this->right->insert(mid+1, R, val));
    }
}

int getkth(node *low, node *high, int L, int R, int val)
{
    if(L==R)
        return L;
    int lsum = high->left->cnt - low->left->cnt;
    int mid = (L+R)>>1;
    if(lsum>=val)
        return getkth(low->left, high->left, L, mid, val);
    else
        return (getkth(low->right, high->right, mid+1, R, val-lsum));
}

int main()
{
    int n, m, i, l, r, k;
    scanint(n);
    scanint(m);
    int arr[n];
    map<int, int> m1;
    for(i=0; i<n; i++){
        scanint(arr[i]);
        m1[arr[i]];
    }
    map<int, int>::iterator it;
    int ind=0;
    int sor[n];
    for(it=m1.begin(); it!=m1.end(); ++it){
        m1[it->first] = ind;
        sor[ind] = it->first;
        ind++;
    }
    tree[0] = new node();
    for(i=1; i<=n; i++)
        tree[i] = tree[i-1]->insert(0, ind, m1[arr[i-1]]);
    while(m--){
        scanint(l);
        scanint(r);
        scanint(k);
        int ans = sor[getkth(tree[l-1], tree[r], 0, ind, k)];
        printf("%d\n", ans);
    }
    return 0;
}
