NoCruelty
时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
64bit IO Format: %lld

题目描述



Given a sequence of integers a_1,\dots,a_n , you need to process m operations.
In an operation l,r,x , you need to update the sequence first, and then query how many different values are there in a_1,\dots,a_x .
When l\le r , the update is sort a_l,\dots,a_r according to ascending order, or the update is sort a_r,\dots,a_l according to descending order.

1\le a_i\le n
1\le l,r,x\le n
1\le n,m\le 10^5

输入描述:

The first line contains two integers n,m .
The next line contains n integers a_1,\dots,a_n .
For the next m lines, each line contains three integers l\oplus c,r\oplus c,x\oplus c , means an operation l,r,x. Where \oplus is bitwise XOR, and c is the answer to the last operation (especially, c=0 for the first operation).

输出描述:

For each operation, output an integer in a line representing the answer.
示例1

输入

复制
9 7
2 2 8 8 2 8 2 1 3
2 2 2
3 7 6
6 7 1
9 6 7
10 11 10
7 0 5
5 1 7

输出

复制
1
2
1
2
3
2
2