## TTM - To the moon

### Background

*To The Moon* is a independent game released in November 2011, it is a role-playing adventure game powered by RPG Maker.

The premise of *To The Moon* is based around a technology that allows us to permanently reconstruct the memory on dying man. In this problem, we'll give you a chance, to implement the logic behind the scene.

### Description

You‘ve been given N integers A[1], A[2],..., A[N]. On these integers, you need to implement the following operations:

- C l r d: Adding a constant d for every {Ai | l <= i <= r}, and increase the timestamp by 1, this is the only operation that will cause the timestamp increase.
- Q l r: Querying the current sum of {Ai | l <= i <= r}.
- H l r t: Querying a history sum of {Ai | l <= i <= r} in time t.
- B t: Back to time t. And once you decide return to a past, you can never be access to a forward edition anymore.

.. N, M ≤ 10^5, |A[i]| ≤ 10^9, 1 ≤ l ≤ r ≤ N, |d| ≤ 10^4 .. the system start from time 0, and the first modification is in time 1, t ≥ 0, and won't introduce you to a future state.

### Input

n m

A1 A2 ... An

... (here following the m operations. )

### Output

... (for each query, simply print the result. )

### Example

Input 1:

10 5 1 2 3 4 5 6 7 8 9 10 Q 4 4 Q 1 10 Q 2 4 C 3 6 3 Q 2 4Output 1:

4 55 9 152 4 0 0 C 1 1 1 C 2 2 -1 Q 1 2 H 1 2 1

Input 2:

Output 2:

0 1

Added by: | xiaodao |

Date: | 2012-04-30 |

Time limit: | 0.100s-0.829s |

Source limit: | 50000B |

Memory limit: | 1536MB |

Cluster: | Cube (Intel G860) |

Languages: | All except: ASM64 |

Resource: | Own Problem, 2012 Multi-University Training Contest 5 |