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 a[200010];
struct seg {
  int val, idx;
} tree1[600010], tree2[600010];
void build(int node, int s, int e) {
  if (s > e) return;
  if (s == e) {
    tree1[node].val = a[s];
    tree1[node].idx = s;
    tree2[node].val = a[s];
    tree2[node].idx = s;
    return;
  }
  int mid = (s + e) / 2;
  build(2 * node, s, mid);
  build(2 * node + 1, mid + 1, e);
  if (tree1[2 * node].val > tree1[2 * node + 1].val)
    tree1[node].idx = tree1[2 * node + 1].idx;
  else
    tree1[node].idx = tree1[2 * node].idx;
  if (tree2[2 * node].val > tree2[2 * node + 1].val)
    tree2[node].idx = tree2[2 * node].idx;
  else
    tree2[node].idx = tree2[2 * node + 1].idx;
  tree1[node].val = min(tree1[2 * node].val, tree1[2 * node + 1].val);
  tree2[node].val = max(tree2[2 * node].val, tree2[2 * node + 1].val);
}
seg query1(int node, int s, int end, int l, int r) {
  if (s > end || s > r || end < l) {
    seg temp;
    temp.val = 1000000000;
    temp.idx = -1;
    return temp;
  }
  if (s >= l && end <= r) return tree1[node];
  seg res1 = query1(2 * node, s, (s + end) / 2, l, r);
  seg res2 = query1(2 * node + 1, (s + end) / 2 + 1, end, l, r);
  seg res;
  if (res1.val < res2.val) {
    res.val = res1.val;
    res.idx = res1.idx;
  } else {
    res.val = res2.val;
    res.idx = res2.idx;
  }
  return res;
}
seg query2(int node, int s, int end, int l, int r) {
  if (s > end || s > r || end < l) {
    seg temp;
    temp.val = -1000000000;
    temp.idx = -1;
    return temp;
  }
  if (s >= l && end <= r) return tree2[node];
  seg res1 = query2(2 * node, s, (s + end) / 2, l, r);
  seg res2 = query2(2 * node + 1, (s + end) / 2 + 1, end, l, r);
  seg res;
  if (res1.val > res2.val) {
    res.val = res1.val;
    res.idx = res1.idx;
  } else {
    res.val = res2.val;
    res.idx = res2.idx;
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  int q;
  cin >> q;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  build(1, 0, n - 1);
  while (q--) {
    int l, r, x;
    scanf("%d %d %d", &l, &r, &x);
    l--;
    r--;
    seg mx = query1(1, 0, n - 1, l, r);
    seg mi = query2(1, 0, n - 1, l, r);
    if (mx.val == x && mi.val == x) {
      printf("-1\n");
    } else if (mx.val == x) {
      printf("%d\n", mi.idx + 1);
    } else
      printf("%d\n", mx.idx + 1);
  }
  return 0;
}