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