#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int N = 1e6 + 10;
const ll INF = 1e18 * 3;
pair<int, int> s[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> s[i].first;
    s[i].second = i;
  }
  for (int i = n - 1; i >= 1; i--) {
    if (s[i].first != s[i + 1].first)
      s[i].second = i;
    else
      s[i].second = s[i + 1].second;
  }
  int l, r, x;
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> x;
    if (s[l].first != x)
      cout << l << endl;
    else {
      if (s[l].second >= r)
        cout << -1 << endl;
      else
        cout << s[l].second + 1 << endl;
    }
  }
}
