#include <bits/stdc++.h>
using namespace std;
inline void splay(int &v) {
  v = 0;
  char c = 0;
  int p = 1;
  while (c < '0' || c > '9') {
    if (c == '-') p = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    v = (v << 3) + (v << 1) + c - '0';
    c = getchar();
  }
  v *= p;
}
int a[200010], t[200010];
int main() {
  int n, m;
  splay(n);
  splay(m);
  for (int i = 1; i <= n; i++) splay(a[i]);
  t[n] = n + 1;
  for (int i = n - 1; i >= 1; i--) {
    if (a[i] == a[i + 1])
      t[i] = t[i + 1];
    else
      t[i] = i + 1;
  }
  for (int i = 1; i <= m; i++) {
    int l, r, x;
    splay(l), splay(r), splay(x);
    if (a[l] != x)
      printf("%d\n", l);
    else {
      if (t[l] <= r)
        printf("%d\n", t[l]);
      else
        printf("-1\n");
    }
  }
  return (0);
}
