#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int inf = 1e9;
const long long INF = 1E18;
int a[maxn], dp[maxn];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  dp[n] = n + 1;
  for (int i = n - 1; i >= 1; i--) {
    int x = a[i];
    if (x == a[i + 1])
      dp[i] = dp[i + 1];
    else
      dp[i] = i + 1;
  }
  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 (dp[l] > r)
        puts("-1");
      else {
        printf("%d\n", dp[l]);
      }
    }
  }
  return 0;
}
