#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int fact[2 * 100005];
long long int func() {
  fact[0] = fact[1] = 1;
  for (long long int i = 2; i < 200001; i++) {
    fact[i] = (fact[i - 1] * i) % 1000000007;
  }
  return 0;
}
int arr[1000005];
int dp[1000005];
int main() {
  int n;
  int m;
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
  }
  dp[n] = n;
  for (int i = n - 1; i > 0; i--) {
    if (arr[i] == arr[i + 1]) {
      dp[i] = dp[i + 1];
    } else {
      dp[i] = i;
    }
  }
  int l, r, p;
  while (m--) {
    scanf("%d", &l);
    scanf("%d", &r);
    scanf("%d", &p);
    if (arr[l] != p) {
      printf("%d\n", l);
    } else {
      if (dp[l] >= r) {
        printf("-1\n");
      } else {
        printf("%d\n", dp[l] + 1);
      }
    }
  }
}
