Little Ali has recently become very interested in lights. That's why he n n-string of…
- User
Little Ali has recently become very interested in lights. That's why he n n-string of lights, each included 1 0 9 10 9 He has bought a lamp and strings with numbers 1 to n n numbered to play with them. Today he decided to play the following game with his father. At each stage of the game, Ali does one of the following:
Three numbers a a and b b that 1 ≤ a , b ≤ n 1≤a,b≤n and x x which 1 ≤ x ≤ 1 0 9 1≤x≤10 9 Selects and lights x x m of each string a Aam to b turns on bam (including both). If the light x If one or more of these strings are on, the status of this light will not change in those strings.
Three numbers a a and b b that 1 ≤ a , b ≤ n 1≤a,b≤n and x x which 1 ≤ x ≤ 1 0 9 1≤x≤10 9 Selects and lights x x m of each string a Aam to b Turns off bam (including both). If the light x Even if one or more of these fields are off, the state of this light will not change in those fields.
Two numbers a a and b b that 1 ≤ a , b ≤ n He chooses 1≤a,b≤n and from his father the total number of light bulbs in the strings a Aam to b bam (including both) asks.
Ali's father is very involved, but he does not want to upset his son. As a result, you are asked to write a program that answers Ali's questions. It should be noted that before the start of the game, Ali turns off all the lights.
input In the first line of the input, two numbers n n and q q, which are the number of strings of lights and the number of game stages, respectively. in each of q q The next line is the description of a stage of the game. In each of these q q first line type of operation with one of the letters +,- or ? It has been determined that they correspond to the first, second and third operations in question. Then the numbers related to that operation are given in the same order as mentioned in the question. That is, any of these q q line to one of the following three doubts:
- a b x
- a b x
? a b
1 ≤ n ≤ 1 0 9 1≤n≤10 9
1 ≤ q ≤ 500
000 1≤q≤500 000 1 ≤ a ≤ b ≤ n 1≤a≤b≤n 1 ≤ x ≤ 1 0 9 1≤x≤10 9
output Print the correct answer on a separate line for each step of the game in which Little Ali asked his father a question.
Sub-issues Constraint score subproblem 1 13 q ≤ 1
000 q≤1000 2 18 x
1 x=1 3 43 x , n , q ≤ 100
000 x, n, q ≤ 100 000 4 26 without additional restrictions Example Sample input 5 11
- 3 4 2 ? 1 3
- 1 5 2 ? 1 3
- 3 3 1 ? 1 3
- 3 3 1 ? 4 5 ? 1 3
- 1 5 1 ? 1 2 Plain text Sample output 1 3 3 2 4 2 c++
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.