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.*;
public final class not_equal_st
{
    static FastScanner sc=new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out=new PrintWriter(System.out);
	static int[] a;
	static Node[] tree1,tree2;
	
	static void build(int node,int l,int r)
	{
		if(l>r)
		{
			return;
		}
		if(l==r)
		{
			tree1[node]=tree2[node]=new Node(l,a[l]);
		}
		else
		{
			int mid=(l+r)>>1;
			build(node<<1,l,mid);
			build(node<<1|1,mid+1,r);
			if(tree1[node<<1].val<tree1[node<<1|1].val)
			{
				tree1[node]=tree1[node<<1];
			}
			else
			{
				tree1[node]=tree1[node<<1|1];
			}
			if(tree2[node<<1].val>tree2[node<<1|1].val)
			{
				tree2[node]=tree2[node<<1];
			}
			else
			{
				tree2[node]=tree2[node<<1|1];
			}
		}
	}
	
	static Node getMin(int node,int s,int e,int l,int r)
	{
		if(s>e || l>e || r<s)
		{
			return new Node(-1,Integer.MAX_VALUE);
		}
		if(l<=s && r>=e)
		{
			return tree1[node];
		}
		else
		{
			int mid=(s+e)>>1;
			Node q1=getMin(node<<1,s,mid,l,r);
			Node q2=getMin(node<<1|1,mid+1,e,l,r);
			if(q1.val<q2.val)
			{
				return q1;
			}
			else
			{
				return q2;
			}
		}
	}
	
	static Node getMax(int node,int s,int e,int l,int r)
	{
		if(s>e || l>e || r<s)
		{
			return new Node(-1,-1);
		}
		if(l<=s && r>=e)
		{
			return tree2[node];
		}
		else
		{
			int mid=(s+e)>>1;
			Node q1=getMax(node<<1,s,mid,l,r);
			Node q2=getMax(node<<1|1,mid+1,e,l,r);
			if(q1.val>q2.val)
			{
				return q1;
			}
			else
			{
				return q2;
			}
		}
	}
	
    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt(),q=sc.nextInt();
		a=new int[n];
		tree1=new Node[4*n];tree2=new Node[4*n];
		for(int i=0;i<n;i++)
		{
			a[i]=sc.nextInt();
		}
		build(1,0,n-1);
		while(q>0)
		{
			int l=sc.nextInt()-1,r=sc.nextInt()-1,x=sc.nextInt();
			Node n1=getMin(1,0,n-1,l,r),n2=getMax(1,0,n-1,l,r);
			if(n1.val==n2.val && n1.val==x)
			{
				out.println("-1");
			}
			else if(n1.val!=x)
			{
				out.println(n1.pos+1);
			}
			else
			{
				out.println(n2.pos+1);
			}
			q--;
		}
		out.close();
    }
}
class Node
{
	int pos,val;
	public Node(int pos,int val)
	{
		this.pos=pos;
		this.val=val;
	}
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}