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 N = 200010;
const int M = 1000010;
inline int red() {
  int r = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') r = r * 10 + ch - '0', ch = getchar();
  return r;
}
struct dat {
  int x, pos;
  bool operator<(const dat a) const {
    if (x == a.x) return pos < a.pos;
    return x < a.x;
  }
} a[N];
int to[N], lt[M], rt[M];
int n, m, x, y, z;
void init() {
  for (int i = n; i >= 1; --i) {
    if (a[i].x != a[i + 1].x) {
      to[i] = a[i].pos + 1;
      lt[a[i].x] = rt[a[i].x] = i;
    } else {
      if (a[i].pos + 1 == a[i + 1].pos)
        to[i] = to[i + 1];
      else
        to[i] = a[i].pos + 1;
      lt[a[i].x] = i;
    }
  }
}
int find(int L, int R, int p) {
  register int M, B = 0;
  while (L <= R) {
    M = (L + R) >> 1;
    if (a[M].pos <= p)
      B = M, L = M + 1;
    else
      R = M - 1;
  }
  return B;
}
int main() {
  n = red(), m = red();
  for (int i = 1; i <= n; ++i) a[i].x = red(), a[i].pos = i;
  sort(a + 1, a + n + 1);
  init();
  while (m--) {
    x = red(), y = red(), z = red();
    if (lt[z] == 0) {
      printf("%d\n", x);
      continue;
    }
    register int tmp = find(lt[z], rt[z], x);
    if (tmp == 0 || a[tmp].pos < x)
      printf("%d\n", x);
    else if (to[tmp] <= y)
      printf("%d\n", to[tmp]);
    else
      printf("-1\n");
  }
}