#include <bits/stdc++.h>
const double eps = 1e-5;
const long long int MOD = 1000000007ll;
const double PI = 3.14159265359;
int INF = 2147483645;
template <class T>
T Max2(T a, T b) {
  return a < b ? b : a;
}
template <class T>
T Min2(T a, T b) {
  return a < b ? a : b;
}
template <class T>
T Max3(T a, T b, T c) {
  return Max2(Max2(a, b), c);
}
template <class T>
T Min3(T a, T b, T c) {
  return Min2(Min2(a, b), c);
}
template <class T>
T Max4(T a, T b, T c, T d) {
  return Max2(Max2(a, b), Max2(c, d));
}
template <class T>
T Min4(T a, T b, T c, T d) {
  return Min2(Min2(a, b), Max2(c, d));
}
using namespace std;
int a[200010];
int pre[200010];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  pre[n] = n;
  for (int i = n - 1; i >= 1; i--) {
    if (a[i] == a[i + 1]) {
      pre[i] = pre[i + 1];
    } else
      pre[i] = i;
  }
  for (int i = 0; i < m; i++) {
    int l, r, x;
    scanf("%d%d%d", &l, &r, &x);
    if (a[l] != x) {
      printf("%d\n", l);
    } else {
      if (pre[l] >= r) {
        printf("-1\n");
      } else {
        printf("%d\n", pre[l] + 1);
      }
    }
  }
  return 0;
}
