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 a[200005];
int seg[4 * 200005];
void build(int idx, int l, int r) {
  if (l == r) {
    seg[idx] = l;
    return;
  }
  int mid = (l + r) / 2;
  build(idx * 2, l, mid);
  build(idx * 2 + 1, mid + 1, r);
  if (a[seg[idx * 2]] < a[seg[idx * 2 + 1]])
    seg[idx] = seg[idx * 2];
  else
    seg[idx] = seg[idx * 2 + 1];
}
int query(int idx, int l, int r, int lx, int rx) {
  if (lx <= l && r <= rx) return seg[idx];
  if (r < lx || l > rx) return -1;
  int mid = (l + r) / 2;
  int il = query(idx * 2, l, mid, lx, rx);
  int ir = query(idx * 2 + 1, mid + 1, r, lx, rx);
  if (il == -1)
    return ir;
  else if (ir == -1)
    return il;
  if (a[il] < a[ir])
    return il;
  else
    return ir;
}
int seg2[4 * 200005];
void build2(int idx, int l, int r) {
  if (l == r) {
    seg2[idx] = l;
    return;
  }
  int mid = (l + r) / 2;
  build2(idx * 2, l, mid);
  build2(idx * 2 + 1, mid + 1, r);
  if (a[seg2[idx * 2]] > a[seg2[idx * 2 + 1]])
    seg2[idx] = seg2[idx * 2];
  else
    seg2[idx] = seg2[idx * 2 + 1];
}
int query2(int idx, int l, int r, int lx, int rx) {
  if (lx <= l && r <= rx) return seg2[idx];
  if (r < lx || l > rx) return -1;
  int mid = (l + r) / 2;
  int il = query2(idx * 2, l, mid, lx, rx);
  int ir = query2(idx * 2 + 1, mid + 1, r, lx, rx);
  if (il == -1)
    return ir;
  else if (ir == -1)
    return il;
  if (a[il] > a[ir])
    return il;
  else
    return ir;
}
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  build(1, 0, n - 1);
  build2(1, 0, n - 1);
  while (q--) {
    int l, r, x;
    cin >> l >> r >> x;
    l--, r--;
    int mn = query(1, 0, n - 1, l, r);
    int mx = query2(1, 0, n - 1, l, r);
    if (a[mn] != x)
      cout << mn + 1 << endl;
    else if (a[mx] != x)
      cout << mx + 1 << endl;
    else
      cout << "-1" << endl;
  }
}