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 n, m;
int mi[800009], mip[800009];
int ma[800009], maap[800009];
void build(int idx, int l, int r) {
  if (l == r) {
    scanf("%d", &mi[idx]);
    ma[idx] = mi[idx];
    mip[idx] = maap[idx] = l;
    return;
  }
  int mid = (l + r) / 2;
  build(2 * idx, l, mid);
  build(2 * idx + 1, mid + 1, r);
  if (mi[2 * idx] < mi[2 * idx + 1]) {
    mi[idx] = mi[2 * idx];
    mip[idx] = mip[2 * idx];
  } else {
    mi[idx] = mi[2 * idx + 1];
    mip[idx] = mip[2 * idx + 1];
  }
  if (ma[2 * idx] > ma[2 * idx + 1]) {
    ma[idx] = ma[2 * idx];
    maap[idx] = maap[2 * idx];
  } else {
    ma[idx] = ma[2 * idx + 1];
    maap[idx] = maap[2 * idx + 1];
  }
}
int query(int idx, int lup, int rup, int l, int r, int x) {
  if (rup < l || r < lup) return -1;
  if (lup <= l && r <= rup) {
    if (mi[idx] == ma[idx] && mi[idx] == x) return -1;
    if (mi[idx] == x) return maap[idx];
    return mip[idx];
  }
  int mid = (l + r) / 2, p, q;
  p = query(2 * idx, lup, rup, l, mid, x);
  q = query(2 * idx + 1, lup, rup, mid + 1, r, x);
  return max(p, q);
}
int main() {
  cin >> n >> m;
  build(1, 1, n);
  while (m--) {
    int l, r, x;
    scanf("%d%d%d", &l, &r, &x);
    printf("%d\n", query(1, l, r, 1, n, x));
  }
  return 0;
}