#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
const int inf = 2e9;
const double eps = 1e-7;
const long long INF = (long long)1e18;
vector<int> v;
int a[N];
int nxt[N];
int n, m, l, r, x;
int main() {
  int lst = 0;
  scanf("%d%d", &(n), &(m));
  for (int i = (1); i <= (n); ++i) scanf("%d", &(a[i]));
  nxt[n] = n + 1;
  for (int i = n - 1; i > 0; i--) {
    if (a[i] == a[i + 1])
      nxt[i] = nxt[i + 1];
    else
      nxt[i] = i + 1;
  }
  while (m--) {
    scanf("%d%d%d", &l, &r, &x);
    if (a[l] != x)
      cout << l << "\n";
    else if (nxt[l] <= r)
      cout << nxt[l] << "\n";
    else
      puts("-1");
  }
  return 0;
}
