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