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 MAXN = 2e5 + 123;
const int mod = 1e9 + 7;
const int INF = 1e9 + 1;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n, m, a[MAXN];
pair<int, int> mn[4 * MAXN], mx[4 * MAXN];
void build(int id = 1, int tl = 1, int tr = n) {
  if (tl == tr) {
    mn[id].first = a[tl];
    mn[id].second = tl;
    mx[id].first = a[tl];
    mx[id].second = tl;
    return;
  }
  int tm = (tl + tr) / 2;
  build(id * 2, tl, tm);
  build(id * 2 + 1, tm + 1, tr);
  mn[id].first = min(mn[id * 2].first, mn[id * 2 + 1].first);
  mn[id].second =
      (mn[id * 2].first < mn[id * 2 + 1].first ? mn[id * 2].second
                                               : mn[id * 2 + 1].second);
  mx[id].first = max(mx[id * 2].first, mx[id * 2 + 1].first);
  mx[id].second =
      (mx[id * 2].first > mx[id * 2 + 1].first ? mx[id * 2].second
                                               : mx[id * 2 + 1].second);
}
pair<int, int> get_min(int l, int r, int id = 1, int tl = 1, int tr = n) {
  if (tl > r || tr < l) return make_pair(INF, 0);
  if (l <= tl && r >= tr) return make_pair(mn[id].first, mn[id].second);
  int tm = (tl + tr) / 2;
  return min(get_min(l, r, id * 2, tl, tm),
             get_min(l, r, id * 2 + 1, tm + 1, tr));
}
pair<int, int> get_max(int l, int r, int id = 1, int tl = 1, int tr = n) {
  if (tl > r || tr < l) return make_pair(0, 0);
  if (l <= tl && r >= tr) return make_pair(mx[id].first, mx[id].second);
  int tm = (tl + tr) / 2;
  return max(get_max(l, r, id + id, tl, tm),
             get_max(l, r, id + id + 1, tm + 1, tr));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  build();
  for (int i = 1; i <= m; i++) {
    int l, r, x;
    cin >> l >> r >> x;
    int maxi = get_max(l, r).first, maxp = get_max(l, r).second;
    int mini = get_min(l, r).first, minp = get_min(l, r).second;
    if (maxi == mini && maxi == x)
      printf("-1\n");
    else
      printf("%d\n", (maxi != x ? maxp : minp));
  }
  return 0;
}