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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CNotEqualOnASegment solver = new CNotEqualOnASegment();
        solver.solve(1, in, out);
        out.close();
    }

    static class CNotEqualOnASegment {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), q = s.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = s.nextInt();
            segtreemn min = new segtreemn(n, a);
            segtreemx max = new segtreemx(n, a);
            min.build(0, n - 1, 1);
            max.build(0, n - 1, 1);
            while (q-- > 0) {
                int l = s.nextInt() - 1, r = s.nextInt() - 1, x = s.nextInt();
                int mn = min.query(l, r, 0, n - 1, 1), mx = max.query(l, r, 0, n - 1, 1);
                //w.println(mn+" "+mx);
                if (a[mn] != x) w.println(mn + 1);
                else if (a[mx] != x) w.println(mx + 1);
                else w.println(-1);
            }
        }

        public class segtreemx {
            public final int n;
            public int[] t;
            public int[] a;

            public segtreemx(int n, int[] a) {
                this.n = n;
                t = new int[n << 2];
                this.a = a;
            }

            public void build(int s, int e, int n) {
                if (s == e) {
                    t[n] = s;
                    return;
                }
                int mid = s + e >> 1;
                build(s, mid, n << 1);
                build(mid + 1, e, n << 1 | 1);
                t[n] = combine(t[n << 1], t[n << 1 | 1]);
            }

            public int query(int qs, int qe, int s, int e, int n) {
                if (s > qe || e < qs) return -1;
                if (s >= qs && e <= qe) return t[n];
                int mid = s + e >> 1;
                return combine(query(qs, qe, s, mid, n << 1), query(qs, qe, mid + 1, e, n << 1 | 1));
            }

            public int combine(int x, int y) {
                if (x == -1) return y;
                if (y == -1) return x;
                if (a[x] > a[y]) return x;
                return y;
            }

        }

        public class segtreemn {
            public final int n;
            public int[] t;
            public int[] a;

            public segtreemn(int n, int[] a) {
                this.n = n;
                t = new int[n << 2];
                this.a = a;
            }

            public void build(int s, int e, int n) {
                if (s == e) {
                    t[n] = s;
                    return;
                }
                int mid = s + e >> 1;
                build(s, mid, n << 1);
                build(mid + 1, e, n << 1 | 1);
                t[n] = combine(t[n << 1], t[n << 1 | 1]);
            }

            public int query(int qs, int qe, int s, int e, int n) {
                if (s > qe || e < qs) return -1;
                if (s >= qs && e <= qe) return t[n];
                int mid = s + e >> 1;
                return combine(query(qs, qe, s, mid, n << 1), query(qs, qe, mid + 1, e, n << 1 | 1));
            }

            public int combine(int x, int y) {
                if (x == -1) return y;
                if (y == -1) return x;
                if (a[x] < a[y]) return x;
                return y;
            }

        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(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 nextInt() {

            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 boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}