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 Educational7C {
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); 
		PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out)); 
		String s=reader.readLine();
		int n=0;
		int m=0;
		int tem=0;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)==' '){
				n=tem;
				tem=0;
			}
			else
				tem=tem*10+s.charAt(i)-'0';
		}
		m=tem;
		int []a=new int[n+2];
		int []l=new int[m+1];
		int []r=new int[m+1];
		int []x=new int[m+1];
		String s1=reader.readLine();
		int len=1;
		for(int i=0;i<s1.length();i++){
			if(s1.charAt(i)==' ')
				len++;
			else
				a[len]=a[len]*10+s1.charAt(i)-'0';
		}
		int []num=new int[n+2];
		for(int i=1;i<=n;i++){
			if(i>1&&a[i-1]==a[i]){
				num[i]=num[i-1];
				continue;
			}
			if(i==n){
				num[i]=n+1;
				break;
			}
			for(int j=i+1;j<=n;j++){
				if(a[j]!=a[i]){
					num[i]=j;
					break;
				}	
				if(j==n)
					num[i]=n+1;
			}
		}
		a[n+1]=-1;
		for(int i=1;i<=m;i++){
			String s2=reader.readLine();
			tem=0;
			int p=0;
			for(;p<s2.length();p++){
				if(s2.charAt(p)==' '){
					p++;
					break;
				}
				else
					tem=tem*10+s2.charAt(p)-'0';
			}
			l[i]=tem;
			tem=0;
			for(;p<s2.length();p++){
				if(s2.charAt(p)==' '){
					p++;
					break;
				}
				else
					tem=tem*10+s2.charAt(p)-'0';
			}
			r[i]=tem;
			tem=0;
			for(;p<s2.length();p++){
				if(s2.charAt(p)==' '){
					p++;
					break;
				}
				else
					tem=tem*10+s2.charAt(p)-'0';
			}
			x[i]=tem;
		}
		for(int i=1;i<=m;i++)
		{
			if(a[l[i]]!=x[i])
				writer.println(l[i]);
			else if(a[num[l[i]]]!=x[i]&&num[l[i]]<=r[i])
				writer.println(num[l[i]]);
			else
				writer.println(-1);
		}
		writer.close();
	}
}