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.awt.Point;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;
import java.math.BigDecimal;

/**
 *
 * @author Mojtaba
 */
public class Main {

    public static void main(String[] args) throws IOException, Exception {
        MyScanner in = new MyScanner(System.in);
        //Scanner in = new Scanner(System.in);
        //Scanner in = new Scanner(new File("input.txt"));

        PrintWriter writer = new PrintWriter(new BufferedOutputStream(System.out));
        StringBuilder sb = new StringBuilder("");

        int n = in.nextInt();
        int m = in.nextInt();
        int[] position = new int[n + 1];
        int[] a = new int[n + 1];
        int lastNumber = -1;
        for (int i = 1, number; i <= n; i++) {
            number = in.nextInt();
            a[i] = number;
            if (number == lastNumber) {
                position[i] = position[i - 1];
            } else {
                position[i] = i;
                lastNumber = number;
            }
        }
        for (int i = 0, l, r, x; i < m; i++) {
            l = in.nextInt();
            r = in.nextInt();
            x = in.nextInt();
            if (a[l] != x) {
                sb.append(l);
            } else if (a[r] != x) {
                sb.append(r);
            } else if (position[l] == position[r] && a[l] == x && a[r] == x) {
                sb.append("-1");
            }else if (position[r] - 1 > l) {
                sb.append(position[r] - 1);
            } else {
                throw new Exception("unexpected");
            }
            sb.append("\n");
        }

        writer.println(sb.toString().trim());
        writer.flush();
        in.close();
    }
}

class MyScanner {

    BufferedReader reader;
    StringTokenizer tokenizer;

    public MyScanner(InputStream stream) {
        this.reader = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public int[] nextIntegerArray(int n) throws IOException {
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    public long[] nextLongArray(int n) throws IOException {
        long[] a = new long[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    public int nextInt(int radix) throws IOException {
        return Integer.parseInt(next(), radix);
    }

    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public long nextLong(int radix) throws IOException {
        return Long.parseLong(next(), radix);
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public BigInteger nextBigInteger() throws IOException {
        return new BigInteger(next());
    }

    public BigInteger nextBigInteger(int radix) throws IOException {
        return new BigInteger(next(), radix);
    }

    public String next() throws IOException {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
            return this.next();
        }
        return tokenizer.nextToken();
    }

    public void close() throws IOException {
        this.reader.close();
    }
}