#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 123;
const int mod = 1e9 + 7;
const int INF = 1e9 + 1;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n, m, a[MAXN];
pair<int, int> mn[4 * MAXN], mx[4 * MAXN];
void build(int id = 1, int tl = 1, int tr = n) {
  if (tl == tr) {
    mn[id].first = a[tl];
    mn[id].second = tl;
    mx[id].first = a[tl];
    mx[id].second = tl;
    return;
  }
  int tm = (tl + tr) / 2;
  build(id * 2, tl, tm);
  build(id * 2 + 1, tm + 1, tr);
  mn[id].first = min(mn[id * 2].first, mn[id * 2 + 1].first);
  mn[id].second =
      (mn[id * 2].first < mn[id * 2 + 1].first ? mn[id * 2].second
                                               : mn[id * 2 + 1].second);
  mx[id].first = max(mx[id * 2].first, mx[id * 2 + 1].first);
  mx[id].second =
      (mx[id * 2].first > mx[id * 2 + 1].first ? mx[id * 2].second
                                               : mx[id * 2 + 1].second);
}
pair<int, int> get_min(int l, int r, int id = 1, int tl = 1, int tr = n) {
  if (tl > r || tr < l) return make_pair(INF, 0);
  if (l <= tl && r >= tr) return make_pair(mn[id].first, mn[id].second);
  int tm = (tl + tr) / 2;
  return min(get_min(l, r, id * 2, tl, tm),
             get_min(l, r, id * 2 + 1, tm + 1, tr));
}
pair<int, int> get_max(int l, int r, int id = 1, int tl = 1, int tr = n) {
  if (tl > r || tr < l) return make_pair(0, 0);
  if (l <= tl && r >= tr) return make_pair(mx[id].first, mx[id].second);
  int tm = (tl + tr) / 2;
  return max(get_max(l, r, id + id, tl, tm),
             get_max(l, r, id + id + 1, tm + 1, tr));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  build();
  for (int i = 1; i <= m; i++) {
    int l, r, x;
    cin >> l >> r >> x;
    int maxi = get_max(l, r).first, maxp = get_max(l, r).second;
    int mini = get_min(l, r).first, minp = get_min(l, r).second;
    if (maxi == mini && maxi == x)
      printf("-1\n");
    else
      printf("%d\n", (maxi != x ? maxp : minp));
  }
  return 0;
}
