#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long a[200005], n, m;
struct ak {
  int mx, mn;
};
ak tree[4 * 200005];
void build(long long node, long long st, long long end) {
  if (st == end) {
    tree[node].mn = st;
    tree[node].mx = st;
    return;
  }
  long long mid = (st + end) / 2;
  build(2 * node, st, mid);
  build(2 * node + 1, mid + 1, end);
  if (a[tree[2 * node].mx] < a[tree[2 * node + 1].mx])
    tree[node].mx = tree[2 * node + 1].mx;
  else
    tree[node].mx = tree[2 * node].mx;
  if (a[tree[2 * node].mn] > a[tree[2 * node + 1].mn])
    tree[node].mn = tree[2 * node + 1].mn;
  else
    tree[node].mn = tree[2 * node].mn;
}
ak query(long long node, long long st, long long end, long long l,
         long long r) {
  if (l > end || r < st) {
    ak ba;
    ba.mn = INT_MAX;
    ba.mx = INT_MAX;
    return ba;
  }
  if (l <= st && r >= end) {
    return tree[node];
  }
  long long md = (st + end) / 2;
  ak lf, rt;
  lf = query(2 * node, st, md, l, r);
  rt = query(2 * node + 1, md + 1, end, l, r);
  ak b;
  if (lf.mx == INT_MAX) {
    return rt;
  }
  if (rt.mx == INT_MAX) {
    return lf;
  }
  if (a[lf.mx] < a[rt.mx]) {
    b.mx = rt.mx;
  } else
    b.mx = lf.mx;
  if (a[lf.mn] > a[rt.mn]) {
    b.mn = rt.mn;
  } else
    b.mn = lf.mn;
  return b;
}
int main() {
  scanf("%lld %lld", &n, &m);
  for (long long i = 1; i < n + 1; i++) scanf("%lld", &a[i]);
  build(1, 1, n);
  while (m--) {
    long long xx, yy, zz;
    scanf("%lld %lld", &xx, &yy);
    scanf("%lld", &zz);
    ak raj = query(1, 1, n, xx, yy);
    if (a[raj.mn] != zz) {
      cout << raj.mn << "\n";
      continue;
    }
    if (a[raj.mx] != zz) {
      cout << raj.mx << "\n";
      continue;
    }
    cout << "-1\n";
  }
}
