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 arr[200001] = {0};
vector<pair<pair<int, int>, pair<int, int> > > segtree(800006);
void buildtree(int start, int end, int index) {
  if (start > end)
    return;
  else if (start == end) {
    segtree[index].first.first = arr[start];
    segtree[index].first.second = start;
    segtree[index].second.first = arr[start];
    segtree[index].second.second = start;
    return;
  } else {
    int mid = (start + end) / 2;
    buildtree(start, mid, index * 2);
    buildtree(mid + 1, end, index * 2 + 1);
    segtree[index].first =
        min(segtree[index * 2].first, segtree[index * 2 + 1].first);
    segtree[index].second =
        max(segtree[index * 2].second, segtree[index * 2 + 1].second);
    return;
  }
}
pair<pair<int, int>, pair<int, int> > query(int start, int end, int sstart,
                                            int send, int index) {
  if (start > end)
    return make_pair(make_pair(10000000, 0), make_pair(0, 0));
  else if (sstart > end || send < start) {
    return make_pair(make_pair(10000000, 0), make_pair(0, 0));
  } else if (sstart <= start && end <= send) {
    return segtree[index];
  } else {
    int mid = (start + end) / 2;
    pair<pair<int, int>, pair<int, int> > A = make_pair(make_pair(10000000, 0),
                                                        make_pair(0, 0)),
                                          B = make_pair(make_pair(10000000, 0),
                                                        make_pair(0, 0));
    if (mid >= sstart) {
      A = query(start, mid, sstart, send, index * 2);
    }
    if ((mid + 1) <= send) {
      B = query(mid + 1, end, sstart, send, index * 2 + 1);
    }
    return (make_pair(min(A.first, B.first), max(A.second, B.second)));
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int m;
  cin >> m;
  for (int i = 0; i < n; i++) cin >> arr[i];
  buildtree(0, n - 1, 1);
  while (m--) {
    int l, r, x;
    cin >> l >> r >> x;
    pair<pair<int, int>, pair<int, int> > p1 = query(0, n - 1, l - 1, r - 1, 1);
    if (p1.first.first != x) {
      cout << p1.first.second + 1 << endl;
    } else if (p1.second.first != x) {
      cout << p1.second.second + 1 << endl;
    } else {
      cout << "-1\n";
    }
  }
}