Problem: You are given array a with n integers and m queries. The i-th query is given with three integers li, ri, xi.

For the i-th query find any position pi (li ≤ pi ≤ ri) so that api ≠ xi.

Input

The first line contains two integers n, m (1 ≤ n, m ≤ 2·105) — the number of elements in a and the number of queries.

The second line contains n integers ai (1 ≤ ai ≤ 106) — the elements of the array a.

Each of the next m lines contains three integers li, ri, xi (1 ≤ li ≤ ri ≤ n, 1 ≤ xi ≤ 106) — the parameters of the i-th query.

Output

Print m lines. On the i-th line print integer pi — the position of any number not equal to xi in segment [li, ri] or the value  - 1 if there is no such number.

Examples

Input

6 4
1 2 1 1 3 5
1 4 1
2 6 2
3 4 1
3 4 2


Output

2
6
-1
4

Solution (in JAVA):

Solution:

import java.io.*;

public class C622 {
    public static void main(String[] args) throws IOException {
        BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] s1 = inp.readLine().split(" ");
        int size = Integer.parseInt(s1[0]);
        int querries = Integer.parseInt(s1[1]);
        String[] s2 = inp.readLine().split(" ");
        int[] given = new int[size];
        for(int i=0;i<size;i++){
            given[i] = Integer.parseInt(s2[i]);
        }
        int[] rightDP = new int[size];
        int[] leftDP = new int[size];
        leftDP[0] = 0;
        rightDP[0] = 0;
        int left = 1;
        int right = size-1;
        for(int i=1;i<size;i++){
            if(given[size-1-i]!=given[size-i]){
                rightDP[size-1-i] = size-i;
                right = size-i;
            }
            else{
                rightDP[size-1-i] = right;
            }
        }
        for(int i=0;i<querries;i++) {
            String[] s3 = inp.readLine().split(" ");
            int a = Integer.parseInt(s3[0]);
            int b = Integer.parseInt(s3[1])-1;
            int c = Integer.parseInt(s3[2]);
            int j = a-1;
            boolean ans = false;
            while (j <= b) {
                if(j==size-1){
                    if(given[j]==c){
                        break;
                    }
                }
                if (given[j] != c) {
                    out.write((j+1) + "\n");
                    ans = true;
                    break;
                } else {
                    j = rightDP[j];
                }
            }
            if (!ans) {
                out.write(-1 + "\n");
            }
        }
       // print(rightDP);
        out.flush();
    }
    static void print(int[] a){
        for(int i=0;i<a.length;i++){
            System.out.print(a[i]);
        }
        System.out.println();
    }
}