#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2 * int(1e5) + 10;
int n, m;
int a[MAXN];
int nxt[MAXN];
class Solution {
 public:
  void solve(std::istream& in, std::ostream& out) {
    in >> n >> m;
    for (int i = 0, lets_stop_here = (int)(n); i < lets_stop_here; i++) {
      in >> a[i];
    }
    nxt[n - 1] = -2;
    for (int i = n - 2, lets_stop_here = (int)(0); i >= lets_stop_here; i--) {
      if (a[i] != a[i + 1]) {
        nxt[i] = i + 1;
      } else {
        nxt[i] = nxt[i + 1];
      }
    }
    for (int i = 0, lets_stop_here = (int)(m); i < lets_stop_here; i++) {
      int l, r, v, rez;
      in >> l >> r >> v;
      l--, r--;
      if (a[l] != v) {
        rez = l;
      } else {
        rez = nxt[l] <= r ? nxt[l] : -2;
      }
      out << rez + 1 << ("\n");
    }
  }
};
void solve(std::istream& in, std::ostream& out) {
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  istream& in = cin;
  ostream& out = cout;
  solve(in, out);
  return 0;
}
