#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, m, l, r, x, h[N], a[N];
int main() {
  scanf("%d%d", &n, &m);
  h[0] = -1;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    if (a[i] == a[i - 1])
      h[i] = h[i - 1];
    else
      h[i] = i - 1;
  }
  while (m--) {
    scanf("%d%d%d", &l, &r, &x);
    if (x != a[r])
      printf("%d\n", r);
    else {
      if (h[r] < l)
        puts("-1");
      else
        printf("%d\n", h[r]);
    }
  }
  return 0;
}
