Sequence

아직 제출이 없습니다시간 제한7초메모리 제한512 MB

문제

Yuta has an array A_1A\_1, A_2A\_2, \ldots, A_nA\_n with nn integers, and he keeps a copy of the initial contents of array AA as AA' (initially, A_i=A_iA'\_i = A\_i). Then he executes mm operations on the array AA.

There are three types of operations:

  • "1 ll rr": Yuta wants to find the sum of A_iA\_i for all ii in \[l,r]\[l, r].
  • "2 ll rr kk": Yuta runs the following pseudocode on the sequence AA: for (int i = l; i <= r; i++) A[i] = A[i - k];
  • "3 ll rr": For all i\[l,r]i \in \[l,r], Yuta changes A_iA\_i back to A_iA'\_i.

Help Yuta execute all the given operations.

입력

The first line of the input contains two integers nn and mm (1n,m21051 \leq n, m \leq 2 \cdot 10^5).

The second line contains nn integers A_iA\_i (0A_i1090 \leq A\_i \leq 10^9).

Then mm lines follow, each line describes an operation in the format shown above. It is guaranteed that 1lrn1 \le l \le r \le n and 1k<l1 \leq k < l.

출력

For each operation of the first type, print a single line with a single integer: the required sum.