AT_abc441_g [ABC441G] Takoyaki and Flip

Description

$ N $ plates are arranged in a straight line from left to right. Let us call the $ i $ -th plate from the left $ (1\le i\le N) $ plate $ i $ . Initially, all plates are placed face-up, and no plates have takoyaki (octopus dumplings) on them. Process a total of $ Q $ queries of the following three types: - Type $ 1 $ : You are given integers $ L,R,X $ . For $ i=L,L+1,\ldots,R $ , if plate $ i $ is placed face-up, place $ X $ takoyaki on plate $ i $ . - Type $ 2 $ : You are given integers $ L,R $ . For $ i=L,L+1,\ldots,R $ , if there is at least one takoyaki on plate $ i $ , eat all the takoyaki on plate $ i $ . Flip plate $ i $ (if the plate is placed face-up, place it face-down; otherwise, place it face-up). - Type $ 3 $ : You are given integers $ L,R $ . Print the maximum number of takoyaki on one plate among plates $ L, $ $ L+1,\ldots, $ $ R $ .

Input Format

The input is given from Standard Input in the following format: > $ N $ $ Q $ > > $ \mathrm{query} _ 1 $ > > $ \mathrm{query} _ 2 $ > > $ \vdots $ > > $ \mathrm{query} _ Q $ Here, $ \mathrm{query} _ i $ represents the $ i $ -th $ (1\le i\le Q) $ query and is given in one of the following formats: > $ t $ $ L $ $ R $ $ X $ > $ t $ $ L $ $ R $ These indicate that the $ i $ -th query is of type $ t $ and the given integers are $ L,R,X $ or $ L,R $ . Type $ 1 $ queries are given in the former format, and other queries are given in the latter format.

Output Format

Let $ q $ be the number of type $ 3 $ queries. Print $ q $ lines. The $ i $ -th line $ (1\le i\le q) $ should contain the answer to the $ i $ -th type $ 3 $ query from the beginning.

Explanation/Hint

### Sample Explanation 1 At the time of each query, the state of each plate and the number of takoyaki on it are as shown in the figure below. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/AT_abc441_g/c34e89e59075e52db4f956ca1d1c634b0b7110e4327a6c6e8d76db0e4f5b67bd.png) At the time of the second query, among plates $ 2 $ and $ 3 $ , the one with more takoyaki is plate $ 3 $ . Thus, print `4`, the number of takoyaki on plate $ 3 $ , on the first line. At the time of the fifth query, among plates $ 1, $ $ 2,\ldots, $ $ 6 $ , the one with the most takoyaki is plate $ 5 $ . Thus, print `6`, the number of takoyaki on plate $ 5 $ , on the second line. At the time of the sixth query, among plates $ 2 $ and $ 3 $ , the one with more takoyaki is plate $ 2 $ . Thus, print `2`, the number of takoyaki on plate $ 2 $ , on the third line. ### Sample Explanation 2 Note that no takoyaki is placed on plates that are placed face-down. Also, note that the answer may be $ 2 ^ {32} $ or more. ### Constraints - $ 1\le N\le2\times10 ^ 5 $ - $ 1\le Q\le2\times10 ^ 5 $ - In all queries, $ 1\le L\le R\le N $ . - In type $ 1 $ queries, $ 1\le X\le10 ^ 9 $ . - There is at least one type $ 3 $ query. - All input values are integers.