import java.io.*;
import java.util.*;
class MKTHNUM{
	static int n;
	static int [][]a;
	static int [][]st;
	public static void main(String []arg) throws IOException{
		InputReader in = new InputReader(System.in);
        OutputWriter out = new OutputWriter(System.out);
		n = in.readInt();
		int m = in.readInt();
		int []tmp = new int[n];
		a = new int[n][2];
		for(int i=0;i<n;i++){
			a[i][0] = in.readInt();
			tmp[i] = a[i][0];
			a[i][1] = i;
		}
		mergeSort(0,n-1);
		st = new int[263005][];
		constructST(0,n-1,0);
		while(m-- > 0){
			int l = in.readInt()-1; 
			int r = in.readInt()-1;
			int k = in.readInt();
			out.printLine(tmp[query(0,n-1,l,r,0,k)]);
			out.flush();
		}
		out.close();
	}

	static void constructST(int s, int e,int i){
		if(e < s){
			return ;
		}
		if(e == s){
			st[i] = new int[1];
			st[i][0] = a[e][1];
			return ;
		}
		int mid = s + (e-s)/2;
		constructST(s,mid,2*i+1);
		constructST(mid+1,e,2*i+2);
		mergeST(i);
	}

	static int query(int s,int e,int qs,int qe,int i,int k){
		if(s == e){
			return st[i][0];
		}
		int upperBound = binarySearch(0,st[2*i+1].length,st[2*i+1],qe);
		int lowerBound = binarySearch(0,st[2*i+1].length,st[2*i+1],qs-1);
		int mid = s + (e-s)/2;
		if(upperBound - lowerBound >= k){
			return query(s,mid,qs,qe,2*i+1,k);
		}else{
			return query(mid+1,e,qs,qe,2*i+2,(k - (upperBound-lowerBound)));
		}
	}

	static int binarySearch(int s,int e,int []arr,int val){
		if(s < e){
			int mid = s + (e-s)/2;
			if(val >= arr[mid]){
				return binarySearch(mid+1,e,arr,val);
			}else{
				return binarySearch(s,mid,arr,val);
			}
		}
		return s;
	}

	static void mergeSort(int s,int e){
		if(s < e){
			int mid = s + (e-s)/2;
			mergeSort(s,mid);
			mergeSort(mid+1,e);
			merge(s,mid,e);
		}
	}

	static void merge(int s,int mid,int e){
		int l1 = mid - s + 1;
		int l2 = e - mid;
		int [][]l = new int[l1][2];
		int [][]r = new int[l2][2];
		for(int i=0;i<l1;i++){
			l[i][0] = a[s+i][0];
			l[i][1] = a[s+i][1];
		}
		for(int i=0;i<l2;i++){
			r[i][0] = a[mid+i+1][0];
			r[i][1] = a[mid+i+1][1];
		}
		int i = 0;
		int j = 0;
		int k = s;
		while(i<l1 && j<l2){
			if(l[i][0] <= r[j][0]){
				a[k][0] = l[i][0];
				a[k++][1] = l[i++][1];
			}else{
				a[k][0] = r[j][0];
				a[k++][1] = r[j++][1];
			}
		}
		while(i<l1){
			a[k][0] = l[i][0];
			a[k++][1] = l[i++][1];
		}
		while(j<l2){
			a[k][0] = r[j][0];
			a[k++][1] = r[j++][1];
		}
	}

	static void mergeST(int i){
		int left = 2*i+1;
		int right = 2*i+2;
		int l1 = st[left].length;
		int l2 = st[right].length;
		st[i] = new int[l1+l2];
		int a = 0;
		int b = 0;
		int c = 0;
		while(a<l1 && b<l2){
			if(st[left][a] <= st[right][b]){
				st[i][c++] = st[left][a++];
			}else{
				st[i][c++] = st[right][b++];
			}
		}
		while(a<l1){
			st[i][c++] = st[left][a++];
		}
		while(b<l2){
			st[i][c++] = st[right][b++];
		}
	}



	//For Fast I/O
	private static class InputReader{
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
 
        public InputReader(InputStream stream){
            this.stream = stream;
        }
 
        public int read(){
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars){
                curChar = 0;
                try{
                    numChars = stream.read(buf);
                } catch (IOException e){
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
 
        public int readInt(){
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-'){
                sgn = -1;
                c = read();
            }
            int res = 0;
            do{
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
 
        public String readString(){
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do{
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
 
        public boolean isSpaceChar(int c){
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
 
        public String next(){
            return readString();
        }
 
        public interface SpaceCharFilter{
            public boolean isSpaceChar(int ch);
        }
    }
 
    private static class OutputWriter{
        private final PrintWriter writer;
 
        public OutputWriter(OutputStream outputStream){
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }
 
        public OutputWriter(Writer writer){
            this.writer = new PrintWriter(writer);
        }
 
        public void print(Object... objects){
            for (int i = 0; i < objects.length; i++){
                if (i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }
 
        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }
 
        public void close(){
            writer.close();
        }
 
        public void flush(){
            writer.flush();
        }
    }
}