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 INF = (-1u) / 2;
const long long int INF2 = (-1ull) / 2;
int a, b, i, c[1011000], j, k, n, m, timer = 0, l, r, x, y;
int cnt = 0, fl = 0, a2, a3 = -1000000, ans = 0;
pair<int, int> t[1000100], t2[1000100], p1, p2;
void build(int v, int tl, int tr) {
  if (tl == tr) {
    t[v] = make_pair(c[tl], tl);
    t2[v] = make_pair(c[tl], tl);
  } else {
    int tm = ((tl + tr) >> 1);
    build((v << 1), tl, tm);
    build((v << 1) + 1, tm + 1, tr);
    t[v] = min(t[(v << 1)], t[(v << 1) + 1]);
    t2[v] = max(t2[(v << 1)], t2[(v << 1) + 1]);
  }
}
pair<int, int> takemn(int v, int tl, int tr, int l, int r) {
  if (l > r)
    return make_pair(1000001, 1000001);
  else if (tl == l && tr == r)
    return t[v];
  else {
    int tm = ((tl + tr) >> 1);
    return min(takemn((v << 1), tl, tm, l, min(r, tm)),
               takemn((v << 1) + 1, tm + 1, tr, max(l, tm + 1), r));
  }
}
pair<int, int> takemx(int v, int tl, int tr, int l, int r) {
  if (l > r)
    return make_pair(-1, 1000001);
  else if (tl == l && tr == r)
    return t2[v];
  else {
    int tm = ((tl + tr) >> 1);
    return max(takemx((v << 1), tl, tm, l, min(r, tm)),
               takemx((v << 1) + 1, tm + 1, tr, max(l, tm + 1), r));
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
  }
  build(1, 1, n);
  for (i = 0; i < k; i++) {
    scanf("%d%d%d", &l, &r, &x);
    p1 = takemn(1, 1, n, l, r);
    if (p1.first >= 1 && p1.first <= 1000000 && p1.first != x) {
      printf("%d\n", p1.second);
      continue;
    }
    p2 = takemx(1, 1, n, l, r);
    if (p2.first >= 1 && p2.first <= 1000000 && p2.first != x)
      printf("%d\n", p2.second);
    else
      printf("-1\n");
  }
  return 0;
}