#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[200005];
int m1[200005][50], m2[200005][50];
pair<int, int> query(int i, int j) {
  int k = int(log(1.0 * j - i) / log(2.0));
  pair<int, int> ret;
  int res = m1[i][k];
  if (a[m1[j - (1 << k) + 1][k]] > a[res]) {
    res = m1[j - (1 << k) + 1][k];
  }
  ret.first = res;
  res = m2[i][k];
  if (a[m2[j - (1 << k) + 1][k]] < a[res]) {
    res = m2[j - (1 << k) + 1][k];
  }
  ret.second = res;
  return ret;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int(i) = (0); (i) < int(n); ++(i)) scanf("%d", a + i);
  for (int(i) = (0); (i) < int(n); ++(i)) m1[i][0] = m2[i][0] = i;
  for (int j = 1; (1 << j) <= n; ++j) {
    for (int i = 0; i + (1 << j) - 1 < n; ++i) {
      if (a[m1[i][j - 1]] > a[m1[i + (1 << (j - 1))][j - 1]])
        m1[i][j] = m1[i][j - 1];
      else
        m1[i][j] = m1[i + (1 << (j - 1))][j - 1];
      if (a[m2[i][j - 1]] < a[m2[i + (1 << (j - 1))][j - 1]])
        m2[i][j] = m2[i][j - 1];
      else
        m2[i][j] = m2[i + (1 << (j - 1))][j - 1];
    }
  }
  int l, r, p;
  for (int(i) = (0); (i) < int(m); ++(i)) {
    scanf("%d %d %d", &l, &r, &p);
    pair<int, int> c = query(l - 1, r - 1);
    if (a[c.first] != p)
      printf("%d\n", c.first + 1);
    else if (a[c.second] != p)
      printf("%d\n", c.second + 1);
    else
      printf("-1\n");
  }
  cin.sync();
  cin.get();
  return 0;
}
