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>
constexpr long long inf = (long long)1e9 + 7ll;
char buff[(int)1e6 + 17];
inline void config_io(const bool& __fastio) {
  if (__fastio) {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
  }
  if (!std::string("").empty()) {
    assert(
        freopen(""
                ".in",
                "r", stdin));
    assert(
        freopen(""
                ".out",
                "w", stdout));
  }
}
using namespace std;
const int maxn = (int)2e5 + 17;
int n, q;
int arr[maxn], logn[maxn];
int mins[20][maxn], mini[20][maxn], maxs[20][maxn], maxi[20][maxn];
void build() {
  for (int i = 1, l = 0; i <= n; ++i) {
    l += ((1 << (l + 1)) == i);
    logn[i] = l;
  }
  for (int k = 1; k <= logn[n]; ++k)
    for (int i = 0; i + (1 << (k - 1)) < n; ++i) {
      mins[k][i] = min(mins[k - 1][i], mins[k - 1][i + (1 << (k - 1))]);
      mini[k][i] = mins[k - 1][i] == mins[k][i]
                       ? mini[k - 1][i]
                       : mini[k - 1][i + (1 << (k - 1))];
      maxs[k][i] = max(maxs[k - 1][i], maxs[k - 1][i + (1 << (k - 1))]);
      maxi[k][i] = maxs[k - 1][i] == maxs[k][i]
                       ? maxi[k - 1][i]
                       : maxi[k - 1][i + (1 << (k - 1))];
    }
}
int getmin(int l, int r) {
  int k = logn[r - l + 1];
  return min(mins[k][l], mins[k][r - (1 << k) + 1]);
}
int getmax(int l, int r) {
  int k = logn[r - l + 1];
  return max(maxs[k][l], maxs[k][r - (1 << k) + 1]);
}
int getminid(int l, int r) {
  int k = logn[r - l + 1];
  return mins[k][l] < mins[k][r - (1 << k) + 1] ? mini[k][l]
                                                : mini[k][r - (1 << k) + 1];
}
int getmaxid(int l, int r) {
  int k = logn[r - l + 1];
  return maxs[k][l] > maxs[k][r - (1 << k) + 1] ? maxi[k][l]
                                                : maxi[k][r - (1 << k) + 1];
}
int main() {
  config_io(false);
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &arr[i]);
    mins[0][i] = maxs[0][i] = arr[i];
    mini[0][i] = maxi[0][i] = i;
  }
  build();
  for (int i = 0; i < q; ++i) {
    int l, r, x;
    scanf("%d %d %d", &l, &r, &x);
    --l, --r;
    if (getmin(l, r) == x && getmax(l, r) == x) {
      printf("-1\n");
      continue;
    }
    if (getmin(l, r) == x)
      printf("%d\n", getmaxid(l, r) + 1);
    else
      printf("%d\n", getminid(l, r) + 1);
  }
  return 0;
}