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> tree[200005 * 4];
int arr[200005];
pair<int, int> merge(pair<int, int> p1, pair<int, int> p2) {
  if (p1.first != -1 && p1.second != -1) {
    return p1;
  }
  if (p2.second != -1 && p2.first != -1) {
    return p2;
  }
  if (p1.first == -1) {
    return p2;
  }
  if (p2.first == -1) {
    return p1;
  }
  if (arr[p1.first] == arr[p2.first]) {
    return p1;
  } else {
    p1.second = p2.first;
    return p1;
  }
}
void init(int node, int a, int b) {
  if (a > b) {
    return;
  }
  if (a == b) {
    tree[node].first = a;
    tree[node].second = -1;
    return;
  }
  init(2 * node, a, (a + b) / 2);
  init(2 * node + 1, (a + b) / 2 + 1, b);
  tree[node] = merge(tree[node * 2], tree[node * 2 + 1]);
}
pair<int, int> query(int node, int a, int b, int i, int j) {
  if (a > b || a > j || b < i) {
    pair<int, int> ret;
    ret.first = ret.second = -1;
    return ret;
  }
  if (a >= i && b <= j) {
    return tree[node];
  }
  pair<int, int> q1 = query(node * 2, a, (a + b) / 2, i, j);
  pair<int, int> q2 = query(2 * node + 1, (a + b) / 2 + 1, b, i, j);
  return merge(q1, q2);
}
int main() {
  int n, m, i, j, k, l, r, x;
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  init(1, 0, n - 1);
  for (i = 0; i < m; i++) {
    scanf("%d %d %d", &l, &r, &x);
    pair<int, int> q = query(1, 0, n - 1, l - 1, r - 1);
    if (arr[q.first] == x) {
      if (q.second != -1) {
        q.second++;
      }
      printf("%d\n", q.second);
    } else {
      q.first++;
      printf("%d\n", q.first);
    }
  }
  return 0;
}