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