#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 5;
int seg[N], ans[N];
vector<pair<int, int> > beg[N], fin[N];
set<pair<int, int> > pending;
set<pair<int, int> >::iterator it1, it2;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> seg[i];
  for (int q = 0; q < m; q++) {
    int l, r, x;
    cin >> l >> r >> x;
    beg[l].emplace_back(x, q);
    fin[r].emplace_back(x, q);
  }
  for (int i = 1; i <= n; i++) {
    for (pair<int, int> xq : beg[i]) pending.insert(xq);
    it2 = pending.lower_bound(make_pair(seg[i], 0));
    it1 = pending.begin();
    while (it1 != it2) ans[(it1++)->second] = i;
    pending.erase(pending.begin(), it2);
    it1 = it2 = pending.lower_bound(make_pair(seg[i] + 1, 0));
    while (it1 != pending.end()) ans[(it1++)->second] = i;
    pending.erase(it2, pending.end());
    for (pair<int, int> xq : fin[i])
      if ((it1 = pending.find(xq)) != pending.end()) {
        ans[xq.second] = -1;
        pending.erase(it1);
      }
  }
  for (int q = 0; q < m; q++) cout << ans[q] << '\n';
}
