Problem: You are given array a with n integers and m queries. The i-th query is given with three integers li, ri, xi.

For the i-th query find any position pi (li ≤ pi ≤ ri) so that api ≠ xi.

Input

The first line contains two integers n, m (1 ≤ n, m ≤ 2·105) — the number of elements in a and the number of queries.

The second line contains n integers ai (1 ≤ ai ≤ 106) — the elements of the array a.

Each of the next m lines contains three integers li, ri, xi (1 ≤ li ≤ ri ≤ n, 1 ≤ xi ≤ 106) — the parameters of the i-th query.

Output

Print m lines. On the i-th line print integer pi — the position of any number not equal to xi in segment [li, ri] or the value  - 1 if there is no such number.

Examples

Input

6 4
1 2 1 1 3 5
1 4 1
2 6 2
3 4 1
3 4 2


Output

2
6
-1
4

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long Set(long long n, long long pos) { return n = n | (1LL << pos); }
long long reset(long long n, long long pos) { return n = n & ~(1LL << pos); }
bool check(long long n, long long pos) { return (bool)(n & (1LL << pos)); }
long long mul(long long a, long long b) {
  long long c;
  c = (a % 1000000007 * b % 1000000007) % 1000000007;
  return c;
}
long long add(long long a, long long b) {
  long long c;
  c = (a % 1000000007 + b % 1000000007) % 1000000007;
  return c;
}
long long sub(long long a, long long b) {
  long long c;
  c = ((a % 1000000007 - b % 1000000007) % 1000000007 + 1000000007) %
      1000000007;
  return c;
}
long long power(long long x, long long y) {
  long long res = 1;
  x = x;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
long long exgcd(long long x, long long y, long long &a, long long &b) {
  int flag = 0;
  long long t, la = 1, lb = 0, ra = 0, rb = 1;
  while (x % y) {
    if (flag == 0)
      la -= x / y * ra, lb -= x / y * rb;
    else
      ra -= x / y * la, rb -= x / y * lb;
    t = x, x = y, y = t % y;
    flag = 1 - flag;
  }
  if (flag == 0)
    a = ra, b = rb;
  else
    a = la, b = lb;
  return y;
}
struct tree {
  long long a, b;
  tree() {}
  tree(long long c, long long d) {
    a = c;
    b = d;
  }
} seg[4 * 200005];
long long arr[200005];
long long n, m;
void build(long long node, long long b, long long e) {
  if (b == e) {
    seg[node].a = b;
    seg[node].b = b;
    return;
  }
  long long mid = (b + e) / 2;
  build(node * 2, b, mid);
  build(node * 2 + 1, mid + 1, e);
  if (arr[seg[node * 2].a] >= arr[seg[node * 2 + 1].a]) {
    seg[node].a = seg[node * 2].a;
  } else {
    seg[node].a = seg[node * 2 + 1].a;
  }
  if (arr[seg[node * 2].b] <= arr[seg[node * 2 + 1].b]) {
    seg[node].b = seg[node * 2].b;
  } else {
    seg[node].b = seg[node * 2 + 1].b;
  }
}
tree query(long long node, long long b, long long e, long long i, long long j) {
  if (b > j || e < i) return tree(0, n + 1);
  if (b >= i && e <= j) return seg[node];
  long long mid = (b + e) / 2;
  tree ans1 = query(node * 2, b, mid, i, j);
  tree ans2 = query(node * 2 + 1, mid + 1, e, i, j);
  tree ans;
  if (arr[ans1.a] >= arr[ans2.a]) {
    ans.a = ans1.a;
  } else {
    ans.a = ans2.a;
  }
  if (arr[ans1.b] <= arr[ans2.b]) {
    ans.b = ans1.b;
  } else {
    ans.b = ans2.b;
  }
  return ans;
}
int main() {
  scanf("%lld", &n);
  scanf("%lld", &m);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &arr[i]);
  }
  arr[n + 1] = 1e18;
  build(1, 1, n);
  for (long long i = 1; i <= m; i++) {
    long long l, r, x;
    scanf("%lld", &l);
    scanf("%lld", &r);
    scanf("%lld", &x);
    tree ans = query(1, 1, n, l, r);
    long long m_ind = ans.b;
    long long ma_ind = ans.a;
    if (arr[ma_ind] == arr[m_ind]) {
      if (arr[ma_ind] != x) {
        printf("%lld\n", ma_ind);
      } else {
        printf("-1\n");
      }
    } else {
      if (arr[ma_ind] != x) {
        printf("%lld\n", ma_ind);
      } else {
        printf("%lld\n", m_ind);
      }
    }
  }
  return 0;
}