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;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int N = 2e5 + 1;
long long powmod(long long a, long long b, long long mod) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
  }
  return res % MOD;
}
int gcd(int a, int b) {
  while (b > 0) {
    int t = a % b;
    a = b, b = t;
  }
  return a;
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
long long is_prime(long long n) {
  if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0)) return 0;
  for (long long i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
    if (n % i == 0) return 0;
  return 1;
}
int modI(int a, int m) {
  int m0 = m, y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    int q = a / m;
    int t = m;
    m = a % m;
    a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
long long mod_inv(long long a, long long m = MOD) {
  return a == 1 ? 1 : m - mod_inv(m % a, a) * m / a;
}
long long choose(long long n, long long r) {
  long long product = 1;
  for (long long i = 0; i < r; i++)
    product = product * (n - i) % MOD * mod_inv(i + 1) % MOD;
  return product;
}
long long getcount(long long n, int k) {
  long long res = (n >> (k + 1)) << k;
  if ((n >> k) & 1) res += n & ((1ll << k) - 1);
  return res;
}
int bit[N];
void init(void) {
  int i;
  for (int i = 0; i < N; i++) bit[i] = 0;
}
void update(int idx, int val) {
  while (idx <= N) {
    bit[idx] = max(bit[idx], val);
    idx += idx & -idx;
  }
}
int pref(int idx) {
  int ans = 0;
  while (idx > 0) {
    ans = max(ans, bit[idx]);
    idx -= idx & -idx;
  }
  return ans;
}
int dx[4] = {-1, +1, 0, 0};
int dy[4] = {0, 0, +1, -1};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  int a[n + 2];
  for (int i = 1; i <= n; i++) cin >> a[i];
  int last[n + 2];
  last[n] = -1;
  for (int i = n - 1; i >= 1; i--) {
    if (a[i] != a[i + 1])
      last[i] = i + 1;
    else
      last[i] = last[i + 1];
  }
  while (m--) {
    int l, r, x;
    cin >> l >> r >> x;
    if (a[l] != x)
      cout << l << "\n";
    else if (last[l] <= r && last[l] != -1)
      cout << last[l] << "\n";
    else
      cout << -1 << "\n";
  }
  return 0;
}