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 class ProC {
	static StreamTokenizer in=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	static int nextInt() throws IOException    
	{  
	    in.nextToken();    
	    return (int)in.nval;     
	}
	static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
	static int n,m,l,r,x,a,b;
	static int[] aa=new int[200005];
	static int[][] max=new int[200005][20];
	static int[][] min=new int[200005][20];
	static int min(int l,int r)
	{
		int k=0;
		while((1<<(k+1))<=r-l+1) k++;
		return aa[min[l][k]]<aa[min[r-(1<<k)+1][k]]?min[l][k]:min[r-(1<<k)+1][k];
	}
	static int max(int l,int r)
	{
		int k=0;
		while((1<<(k+1))<=r-l+1) k++;
		return aa[max[l][k]]>aa[max[r-(1<<k)+1][k]]?max[l][k]:max[r-(1<<k)+1][k];
	}

	public static void main(String[] args) throws IOException {
		//Scanner in=new Scanner(System.in);
		n=nextInt();m=nextInt();
		for(int i=1;i<=n;i++)
			aa[i]=nextInt();
		for(int i=1;i<=n;i++)
			max[i][0]=min[i][0]=i;
		for(int j=1;(1<<j)<=n;j++)
		for(int i=1;i+(1<<j)-1<=n;i++)
		{
			max[i][j]=aa[max[i][j-1]]>aa[max[i+(1<<(j-1))][j-1]]?max[i][j-1]:max[i+(1<<(j-1))][j-1];
			min[i][j]=aa[min[i][j-1]]<aa[min[i+(1<<(j-1))][j-1]]?min[i][j-1]:min[i+(1<<(j-1))][j-1];
		}
		for(int i=0;i<m;i++)
		{
			l=nextInt();r=nextInt();
			x=nextInt();
			a=min(l,r);b=max(l,r);
			if(aa[a]!=x) out.println(a);
			else if(aa[b]!=x) out.println(b);
			else out.println(-1);
		}
		out.flush();
	}
}