#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int N = 2e5;
int32_t n, m, a[N + 1], b[N + 1];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout << fixed;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = n, j = n + 1; i >= 1; i--) {
    b[i] = j;
    if (a[i - 1] != a[i]) j = i;
  }
  while (m-- > 0) {
    int l, r, x;
    cin >> l >> r >> x;
    cout << (a[l] != x ? l : b[l] <= r ? b[l] : -1) << '\n';
  }
  return 0;
}
