#P5350. 序列

序列

Description

There is a sequence a1na_{1\sim n} and several operations.

  • 1 l r \mathrm{1\ l \ r \ }: Find the sum from ala_l to ara_r.
  • 2 l r val \mathrm{2\ l \ r \ val \ }: Assign val\mathrm{val} to ala_l through ara_r.
  • 3 l r val \mathrm{3\ l \ r \ val\ }: Add val\mathrm{val} to ala_l through ara_r.
  • 4 l1 r1 l2 r2\mathrm{4\ l_1 \ r_1 \ l_2 \ r_2 }: Copy al1a_{l_1} through ar1a_{r_1} to the range al2a_{l_2} through ar2a_{r_2}.
  • 5 l1 r1 l2 r2\mathrm{5\ l_1 \ r_1 \ l_2 \ r_2 }: Swap al1a_{l_1} through ar1a_{r_1} with al2a_{l_2} through ar2a_{r_2}.
  • 6 l r \mathrm{6\ l \ r \ }: Reverse ala_l through ara_r.

Input Format

The first line contains two numbers nn and mm, the length of the sequence and the number of operations.

The second line contains nn numbers, which are a1na_{1\sim n}.

The next mm lines each describe an operation type and several corresponding integers.

Output Format

Print several lines. For each operation of type 11, output the answer.

Since the answer may be too large, take it modulo 109+710^9+7.

On the last line, output the sequence a1na_{1\sim n}. It should also be taken modulo.

10 10
7 1 3 2 2 4 0 1 2 2 
4 10 10 3 3
3 4 10 5
6 6 7
6 9 10
1 10 10
5 9 10 6 7
2 8 10 0
5 4 4 5 5
5 2 4 8 10
3 3 9 0
7
7 0 0 0 7 7 7 1 2 7

Hint

Please pay attention to constant-factor optimizations.

For operations 44 and 55, it is guaranteed that r1l1=r2l2r_1-l_1=r_2-l_2 and the intervals do not overlap.

The testdata is guaranteed to be random.

For 30%30\% of the testdata,  n,m103 \ n,m\le 10^3\ .

For 50%50\% of the testdata,  n,m5×104 \ n,m\le 5\times 10^4\ .

For 70%70\% of the testdata,  n,m1.5×105 \ n,m\le 1.5\times 10^5\ .

For 100%100\% of the testdata,  n,m3×105 \ n,m\le 3\times 10^5\  0ai,val<109+7\ 0\le a_i,\mathrm{val}< 10^9+7

Translated by ChatGPT 5