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.util.*;
import java.io.*;

public class Main {
    static final int N = 222222;
    static int t[] = new int[N << 2];
    static int g[] = new int[N << 2];
    static int a[] = new int[N];
    static void build(int v, int l, int r)
    {
        if(l == r)
        {
            t[v] = l;
            g[v] =  l;
            return;
        }
        int m = (l + r) >> 1;
        build(v << 1, l, m);
        build(v << 1 | 1, m + 1, r);
        if(a[t[v << 1]] < a[t[v << 1 | 1]])
            t[v] = t[v << 1];
        else
            t[v] = t[v << 1 | 1];
        if(a[g[v << 1]] > a[g[v << 1 | 1]])
            g[v] = g[v << 1];
        else
            g[v] = g[v << 1 | 1];        
    }
    
    static int get(int v, int l, int r, int foo, int hoo)
    {
        if(l > hoo || r < foo)
            return -1;
        if(l >= foo && r <= hoo)
            return t[v];
        int m = (l + r) >> 1;
        int p1 = get(v << 1, l, m, foo, hoo);
        int p2 = get(v << 1 | 1, m + 1, r, foo, hoo);
        if(p1 == -1)
                return p2;
        if(p2 == -1)
                return p1;
        if(a[p1] < a[p2])
             return p1;
       else
            return p2;
    }

    static int teg(int v, int l, int r, int foo, int hoo)
    {
        if(l > hoo || r < foo)
            return -1;
        if(l >= foo && r <= hoo)
            return g[v];
        int m = (l + r) >> 1;
        int p1 = teg(v << 1, l, m, foo, hoo);
        int p2 = teg(v << 1 | 1, m + 1, r, foo, hoo);
        if(p1 == -1)
                return p2;
        if(p2 == -1)
                return p1;
        if(a[p1] > a[p2])
             return p1;
       else
            return p2;
    }
    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	public static int nextInt()throws IOException { in.nextToken(); return (int)in.nval; }
	public static String next()throws IOException { in.nextToken(); return (String)in.sval; }
	static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String args[]) throws IOException
    {
        int n = nextInt();
        int m = nextInt();
        for(int i = 1; i <= n; i ++)
            a[i] = nextInt();
        build(1, 1, n);
        for(int i = 1; i <= m; i ++)
        {
            int l = nextInt();
            int r = nextInt();
            int x = nextInt();
            int mn = get(1, 1, n, l, r);
            int mx = teg(1, 1, n, l, r);
            int ans = -1;
            if(a[mn] == a[mx])
            {
                if(a[mn] == x)
                    ans = -1;
                else
                    ans = mn;
            }
            else
            {
                if(a[mn] == x)
                    ans = mx;
                else
                    ans = mn;
            }
            out.printf("%d\n", ans);
        }
        out.flush();
        out.close();
        
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }    
}