No tag edit access

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-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Dec/06/2019 14:59:49 (g2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|