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.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class SNSTemplate implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Throwable e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    public static void main(String[] args) {
        new Thread(null, new SNSTemplate(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    class Edge implements Comparable<Edge> {
        double time;
        int to;

        Edge(double time, int to) {
            this.time = time;
            this.to = to;
        }

        @Override
        public int compareTo(Edge o) {
            return Double.compare(time, o.time);
        }
    }

    double euq(double x, double y, double ox, double oy) {
        return Math.sqrt((x - ox) * (x - ox) + (y - oy) * (y - oy));
    }

    void solve() throws IOException {
        int n = readInt();
        int m = readInt();
        int[] a = readIntArray(n);
        int[] other = new int[n];
        Arrays.fill(other, -1);
        ArrayList<Integer> temp = new ArrayList<>();
        temp.add(0);
        for (int i = 1; i < n; i++) {
            if (a[i] == a[i - 1]) {
                temp.add(i);
            } else {
                for (int x : temp) {
                    other[x] = i;
                }
                temp.clear();
                temp.add(i);
            }
        }
        for (int i = 0; i < m; i++) {
            int l = readInt() - 1;
            int r = readInt() - 1;
            int x = readInt();
            if (x != a[l]) {
                out.println(l + 1);
            } else {
                if (other[l] == -1 || other[l] > r) {
                    out.println(-1);
                } else {
                    out.println(other[l] + 1);
                }
            }
        }
    }

}