#include <bits/stdc++.h>
using namespace std;
int n, m, a[200010], p[200010];
void Init() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  p[n] = n;
  for (int i = n - 1; i; --i) p[i] = a[i] == a[i + 1] ? p[i + 1] : i;
}
void Query() {
  int i, l, r, x;
  for (i = 1; i <= m; ++i) {
    scanf("%d%d%d", &l, &r, &x);
    if (a[l] == x) {
      if (p[l] >= r)
        printf("-1\n");
      else
        printf("%d\n", p[l] + 1);
    } else
      printf("%d\n", l);
  }
}
int main() {
  Init();
  Query();
  return 0;
}
