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;
long long mod = 1e9 + 7;
long long a[200005], n, m;
struct ak {
  int mx, mn;
};
ak tree[4 * 200005];
void build(long long node, long long st, long long end) {
  if (st == end) {
    tree[node].mn = st;
    tree[node].mx = st;
    return;
  }
  long long mid = (st + end) / 2;
  build(2 * node, st, mid);
  build(2 * node + 1, mid + 1, end);
  if (a[tree[2 * node].mx] < a[tree[2 * node + 1].mx])
    tree[node].mx = tree[2 * node + 1].mx;
  else
    tree[node].mx = tree[2 * node].mx;
  if (a[tree[2 * node].mn] > a[tree[2 * node + 1].mn])
    tree[node].mn = tree[2 * node + 1].mn;
  else
    tree[node].mn = tree[2 * node].mn;
}
ak query(long long node, long long st, long long end, long long l,
         long long r) {
  if (l > end || r < st) {
    ak ba;
    ba.mn = INT_MAX;
    ba.mx = INT_MAX;
    return ba;
  }
  if (l <= st && r >= end) {
    return tree[node];
  }
  long long md = (st + end) / 2;
  ak lf, rt;
  lf = query(2 * node, st, md, l, r);
  rt = query(2 * node + 1, md + 1, end, l, r);
  ak b;
  if (lf.mx == INT_MAX) {
    return rt;
  }
  if (rt.mx == INT_MAX) {
    return lf;
  }
  if (a[lf.mx] < a[rt.mx]) {
    b.mx = rt.mx;
  } else
    b.mx = lf.mx;
  if (a[lf.mn] > a[rt.mn]) {
    b.mn = rt.mn;
  } else
    b.mn = lf.mn;
  return b;
}
int main() {
  scanf("%lld %lld", &n, &m);
  for (long long i = 1; i < n + 1; i++) scanf("%lld", &a[i]);
  build(1, 1, n);
  while (m--) {
    long long xx, yy, zz;
    scanf("%lld %lld", &xx, &yy);
    scanf("%lld", &zz);
    ak raj = query(1, 1, n, xx, yy);
    if (a[raj.mx] != zz)
      cout << raj.mx;
    else if (a[raj.mn] != zz)
      cout << raj.mn;
    else
      cout << "-1";
    printf("\n");
  }
}