408360: GYM103104 K Chtholly and World-End Battle

Memory Limit:1024 MB Time Limit:0 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

K. Chtholly and World-End Battletime limit per test4.0 smemory limit per test1024 megabytesinputstandard inputoutputstandard output

$$$\textit{ - The life is not, for comparing things.}$$$

$$$\textit{ - So I hold both of light and shadow.}$$$

$$$\textit{ - The rays of stars, will bring me to you.}$$$

$$$\textit{ - Through the dark nights, I see the way to be shined.}$$$

Chtholly gives you an integer sequence $$$a$$$ of length $$$n$$$, and $$$m$$$ queries. In each query, an interval $$$[l,r]$$$ and a specific value $$$v$$$ are given. You need to check every elements $$$a_i$$$ in $$$a_l, \ldots ,a_r$$$ successively, modify $$$v$$$ to $$$|v-a_i|$$$, and tell Chtholly the value of $$$v$$$ after the modification.

Input

The first line contains two integers $$$n, m \; (1 \leq n,m \leq 10^5)$$$, representing the length of the sequence and the number of queries.

The second line contains $$$n$$$ numbers, separated by spaces, representing the sequence $$$a$$$.

The next $$$m$$$ lines, three integers $$$l,r,v$$$ separated by spaces on each line, represents a query. The input numbers of the queries should take bitwise XOR to $$$lastans$$$, which equals to the answer to last query. For the first query, $$$lastans$$$ equals to $$$0$$$.

It is guaranteed that $$$1\le a_i, v \le10^5$$$, and $$$l \leq r$$$ after decoding correctly.

Output

For each query, output one line denotes the value of $$$v$$$ you get after the modification.

ExampleInput
5 5
4 5 2 5 3
3 5 3
3 3 0
5 0 6
5 0 5
6 0 4
Output
1
4
4
5
1
Note

The real value of $$$v$$$ of the queries are $$$3,1,2,1,1$$$, and the queried intervals are $$$[3,5], \,[2,2], \,[1,4], \,[1,4], \,[3,5]$$$.

加入题单

上一题 下一题 算法标签: