Jian-Jia is building a wall by stacking bricks of the same size together. This wall consists of
Jian-Jia builds the wall as follows. Initially there are no bricks in any column. Then, Jian-Jia goes through
- In an adding phase, Jian-Jia adds bricks to those columns in the given range that have less than
bricks, so that they have exactly bricks. He does nothing on the columns having or more bricks. - In a removing phase, Jian-Jia removes bricks from those columns in the given range that have more than
bricks, so that they have exactly bricks. He does nothing on the columns having bricks or less.
Your task is to determine the final shape of the wall.
Example
We assume that there are
phase | type | range | height |
---|---|---|---|
0 | add | columns |
|
1 | remove | columns |
|
2 | remove | columns |
|
3 | add | columns |
|
4 | add | columns |
|
5 | remove | columns |
Since all columns are initially empty, after phase
Given the description of the
Input Specification
- Line
of input consists of the two integers , and . is the number of columns of the wall, and is the number of phases. - Line
of input each consists of the format: . is the type of phase : for an adding phase and for a removing phase, for .- the range of columns in phase
starts with column and ends with column (including both endpoints and ), for . You will always have . is the height parameter of phase , for .
Output Specification
The output should consist of
Sample Input 1
10 3
1 3 4 91220
1 5 9 48623
2 3 5 39412
Sample Output 1
0
0
0
39412
39412
39412
48623
48623
48623
48623
Sample Input 2
10 6
1 1 8 4
2 4 9 1
2 3 6 5
1 0 5 3
1 2 2 5
2 6 7 0
Sample Output 2
3
4
5
4
3
3
0
0
1
0
Subtasks
For all subtasks the height parameters of all phases are nonnegative integers less or equal to
subtask | points | note | ||
---|---|---|---|---|
1 | 8 | no additional limits | ||
2 | 24 | all adding phases are before all removing phases | ||
3 | 29 | no additional limits | ||
4 | 39 | no additional limits |
Comments