#include <bits/stdc++.h>
using namespace std;
int n, m;
int mi[800009], mip[800009];
int ma[800009], maap[800009];
void build(int idx, int l, int r) {
  if (l == r) {
    scanf("%d", &mi[idx]);
    ma[idx] = mi[idx];
    mip[idx] = maap[idx] = l;
    return;
  }
  int mid = (l + r) / 2;
  build(2 * idx, l, mid);
  build(2 * idx + 1, mid + 1, r);
  if (mi[2 * idx] < mi[2 * idx + 1]) {
    mi[idx] = mi[2 * idx];
    mip[idx] = mip[2 * idx];
  } else {
    mi[idx] = mi[2 * idx + 1];
    mip[idx] = mip[2 * idx + 1];
  }
  if (ma[2 * idx] > ma[2 * idx + 1]) {
    ma[idx] = ma[2 * idx];
    maap[idx] = maap[2 * idx];
  } else {
    ma[idx] = ma[2 * idx + 1];
    maap[idx] = maap[2 * idx + 1];
  }
}
int query(int idx, int lup, int rup, int l, int r, int x) {
  if (rup < l || r < lup) return -1;
  if (lup <= l && r <= rup) {
    if (mi[idx] == ma[idx] && mi[idx] == x) return -1;
    if (mi[idx] == x) return maap[idx];
    return mip[idx];
  }
  int mid = (l + r) / 2, p, q;
  p = query(2 * idx, lup, rup, l, mid, x);
  q = query(2 * idx + 1, lup, rup, mid + 1, r, x);
  return max(p, q);
}
int main() {
  cin >> n >> m;
  build(1, 1, n);
  while (m--) {
    int l, r, x;
    scanf("%d%d%d", &l, &r, &x);
    printf("%d\n", query(1, l, r, 1, n, x));
  }
  return 0;
}
