#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  long long int i;
  vector<int> v(n + 1, 0);
  for (i = 1; i <= n; i++) {
    cin >> v[i];
  }
  int dp[n + 1], l[m + 1], r[m + 1];
  memset(dp, 0, sizeof(dp));
  dp[n] = n;
  for (long long int i = n - 1; i >= 1; i--) {
    if (v[i] == v[i + 1])
      dp[i] = dp[i + 1];
    else
      dp[i] = i;
  }
  for (i = 1; i <= m; i++) {
    int x;
    cin >> l[i] >> r[i] >> x;
    if (v[l[i]] != x)
      cout << l[i] << "\n";
    else if (dp[l[i]] >= r[i])
      cout << -1 << "\n";
    else
      cout << dp[l[i]] + 1 << "\n";
  }
  return 0;
}
