#include <bits/stdc++.h>
using namespace std;
int a[200005];
int seg[4 * 200005];
void build(int idx, int l, int r) {
  if (l == r) {
    seg[idx] = l;
    return;
  }
  int mid = (l + r) / 2;
  build(idx * 2, l, mid);
  build(idx * 2 + 1, mid + 1, r);
  if (a[seg[idx * 2]] < a[seg[idx * 2 + 1]])
    seg[idx] = seg[idx * 2];
  else
    seg[idx] = seg[idx * 2 + 1];
}
int query(int idx, int l, int r, int lx, int rx) {
  if (lx <= l && r <= rx) return seg[idx];
  if (r < lx || l > rx) return -1;
  int mid = (l + r) / 2;
  int il = query(idx * 2, l, mid, lx, rx);
  int ir = query(idx * 2 + 1, mid + 1, r, lx, rx);
  if (il == -1)
    return ir;
  else if (ir == -1)
    return il;
  if (a[il] < a[ir])
    return il;
  else
    return ir;
}
int seg2[4 * 200005];
void build2(int idx, int l, int r) {
  if (l == r) {
    seg2[idx] = l;
    return;
  }
  int mid = (l + r) / 2;
  build2(idx * 2, l, mid);
  build2(idx * 2 + 1, mid + 1, r);
  if (a[seg2[idx * 2]] > a[seg2[idx * 2 + 1]])
    seg2[idx] = seg2[idx * 2];
  else
    seg2[idx] = seg2[idx * 2 + 1];
}
int query2(int idx, int l, int r, int lx, int rx) {
  if (lx <= l && r <= rx) return seg2[idx];
  if (r < lx || l > rx) return -1;
  int mid = (l + r) / 2;
  int il = query2(idx * 2, l, mid, lx, rx);
  int ir = query2(idx * 2 + 1, mid + 1, r, lx, rx);
  if (il == -1)
    return ir;
  else if (ir == -1)
    return il;
  if (a[il] > a[ir])
    return il;
  else
    return ir;
}
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  build(1, 0, n - 1);
  build2(1, 0, n - 1);
  while (q--) {
    int l, r, x;
    cin >> l >> r >> x;
    l--, r--;
    int mn = query(1, 0, n - 1, l, r);
    int mx = query2(1, 0, n - 1, l, r);
    if (a[mn] != x)
      cout << mn + 1 << endl;
    else if (a[mx] != x)
      cout << mx + 1 << endl;
    else
      cout << "-1" << endl;
  }
}
