P5586 [P5350] Sequence (Enhanced Version)

Background

This problem is an enhanced version of [P5350](https://www.luogu.org/problem/P5350). This problem is quite friendly and does not try to restrict memory usage.

Description

There is a sequence $a_n$ and $q$ operations. - `1 l r` Query the sum of the interval $[l,r]$. - `2 l r k` Assign all values in the interval $[l,r]$ to $k$. - `3 l r k` Add $k$ to all values in the interval $[l,r]$. - `4 l1 r1 l2 r2` Copy the interval $[l_1,r_1]$ to $[l_2,r_2]$. - `5 l1 r1 l2 r2` Swap the intervals $[l_1,r_1]$ and $[l_2,r_2]$. - `6 l r` Reverse the interval $[l,r]$. In the end, you also need to output the entire sequence. All outputs should be taken modulo $10^9+7$. To block some brute-force or hacky solutions, **this problem is strictly online**. In each operation, except for the first number, all other numbers must be XORed with $\text{last}$ to obtain the actual operation. $\text{last}$ is the answer of the previous type $1$ operation $\pmod{10^9 + 7}$, and initially $\text{last} = 0$.

Input Format

The first line contains two positive integers $n,q$, representing the sequence length and the number of operations. The second line contains $n$ positive integers, representing the sequence $a$. The next $q$ lines each describe one operation.

Output Format

For each type $1$ operation, output one integer per line as the answer. In the last line, output $n$ integers, representing the final sequence $a$.

Explanation/Hint

Constraints $1\le n,q \le 3\times 10^5$ $0\le a_i,k \le 10^9$ For operations $4$ and $5$, it is guaranteed that $r_1-l_1 = r_2-l_2$ and $[l_1,r_1] \cap [l_2,r_2] = \varnothing$. **The testdata is not guaranteed to be random**, and there is **no grading by subtasks**. If you want to submit ODT, just forget it. Translated by ChatGPT 5