#Lutece1858. Unintended Consequences

Unintended Consequences

Migrated from Lutece 1858 Unintended Consequences

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

You are given an array AA of size NN, and here's an extra BB array of size NN, initially, each element of the BB array is zero.

You need support QQ queries of following three types.

  • 11 ll rr xx: Add xx to Al,Al+1,...,ArA_l,A_{l+1},...,A_r. (1lrN,0X<232)( 1 \leq l \leq r \leq N , 0 \leq X < 2^{32})

  • 22 ll rr kk bb: Make Bi=Bi+kAi+bB_i = B_i + k \cdot A_i + b for i[l,r]i \subseteq [l,r]. (1lrN,0k,b<232)( 1 \leq l \leq r \leq N , 0 \leq k,b < 2^{32})

  • 33 ll rr: Query i=lrBimod232\sum_{i=l}^{r}B_i \mod 2^{32}. (1lrN)( 1 \leq l \leq r \leq N)

Input

The first line contains two integers NN (1N105)(1 \leq N \leq 10^5) and QQ (1Q4105)(1 \leq Q \leq 4 \cdot 10^5).

The next line contains NN integers indicates each element of AiA_i (0Ai<232)( 0 \leq A_i < 2^{32}).

Each of the next QQ lines contains a query in the format given in the statement.

Output

For each query of type 33, print the corresponding answer in a single line.

Samples

6 4
7 7 2 0 0 2
3 2 4
1 2 5 4
2 2 3 7 6
3 1 5
0
131

Resources

The 16th UESTC Programming Contest Preliminary