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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int nCrevenoroddfinder(int n, int r) {
  int a = r;
  int b = n - r;
  for (int i = 0; i < 30; i++) {
    int x = 1 << i;
    if ((x & a) && (x & b)) {
      return 0;
    }
  }
  return 1;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
bool isperfect(long long n) {
  long long y = sqrt(n);
  if (n % y == 0 && y * y == n) return true;
  return false;
}
bool comp(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first) return a.second > b.second;
  return a.first < b.first;
}
long long powi(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a);
    b = b >> 1;
    a = (a * a);
  }
  return ans;
}
bool isprime(long long n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
bool prime[10000000];
void seive() {
  prime[1] = true;
  for (int i = 2; i * i < 10000000; i++) {
    if (prime[i]) continue;
    for (int j = i * i; j < 10000000; j += i) {
      prime[j] = true;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<long long int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  long long dp[n];
  dp[n - 1] = n;
  for (int i = n - 2; i >= 0; i--) {
    if (v[i] != v[i + 1])
      dp[i] = i + 1;
    else
      dp[i] = dp[i + 1];
  }
  for (int i = 0; i < m; i++) {
    long long l, r, x;
    cin >> l >> r >> x;
    long long ans;
    l--, r--;
    if (v[l] != x)
      ans = l;
    else
      ans = dp[l];
    if (ans > r) ans = -2;
    cout << ans + 1 << endl;
  }
}