#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
int n, m;
int a[MAXN], p1[MAXN], p2[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = n - 1; i >= 0; i--) {
    if (i == (n - 1))
      p2[i] = -1;
    else if (a[i + 1] != a[i])
      p2[i] = i + 1;
    else
      p2[i] = p2[i + 1];
  }
  while (m) {
    m--;
    int l, r, x;
    cin >> l >> r >> x;
    if (a[l - 1] != x)
      cout << l << endl;
    else if (p2[l - 1] <= (r - 1) && p2[l - 1] != -1)
      cout << p2[l - 1] + 1 << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}
