Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
C. Not Equal on a Segment

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou are given array *a* with *n* integers and *m* queries. The *i*-th query is given with three integers *l*_{i}, *r*_{i}, *x*_{i}.

For the *i*-th query find any position *p*_{i} (*l*_{i} ≤ *p*_{i} ≤ *r*_{i}) so that *a*_{pi} ≠ *x*_{i}.

Input

The first line contains two integers *n*, *m* (1 ≤ *n*, *m* ≤ 2·10^{5}) — the number of elements in *a* and the number of queries.

The second line contains *n* integers *a*_{i} (1 ≤ *a*_{i} ≤ 10^{6}) — the elements of the array *a*.

Each of the next *m* lines contains three integers *l*_{i}, *r*_{i}, *x*_{i} (1 ≤ *l*_{i} ≤ *r*_{i} ≤ *n*, 1 ≤ *x*_{i} ≤ 10^{6}) — the parameters of the *i*-th query.

Output

Print *m* lines. On the *i*-th line print integer *p*_{i} — the position of any number not equal to *x*_{i} in segment [*l*_{i}, *r*_{i}] 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

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Mar/05/2021 11:12:00 (h1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|