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;
pair<int, int> t[1000006], tr;
int a[200005], INF = 1e7, n, m, x, y, z;
pair<int, int> comb(pair<int, int> l, pair<int, int> r) {
  return make_pair(a[l.first] < a[r.first] ? l.first : r.first,
                   a[l.second] > a[r.second] ? l.second : r.second);
}
void build(int v, int tl, int tr) {
  if (tl == tr)
    t[v] = make_pair(tl, tl);
  else {
    int tm = (tl + tr) >> 1;
    build(v + v, tl, tm);
    build(v + v + 1, tm + 1, tr);
    t[v] = comb(t[v + v], t[v + v + 1]);
  }
}
pair<int, int> get(int v, int tl, int tr, int l, int r) {
  if (l > r) return make_pair(n, n + 1);
  if (tl == l && tr == r) return t[v];
  int tm = (tl + tr) >> 1;
  return comb(get(v + v, tl, tm, l, min(r, tm)),
              get(v + v + 1, tm + 1, tr, max(l, tm + 1), r));
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) cin >> a[i];
  a[n] = INF;
  a[n + 1] = -INF;
  build(1, 0, n - 1);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &x, &y, &z);
    tr = get(1, 0, n - 1, x - 1, y - 1);
    if (a[tr.first] != z)
      printf("%d\n", tr.first + 1);
    else if (a[tr.second] != z)
      printf("%d\n", tr.second + 1);
    else
      printf("-1\n");
  }
}