#SGM0000063. DZY yêu màu sắc (DZY Loves Colors)
DZY yêu màu sắc (DZY Loves Colors)
DZY Loves Colors
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are ribbon units. Initially unit has color and colorfulness 0. Painting a unit whose current color is with color increases its colorfulness by and changes its color to .
Process operations:
1 l r x: paint every unit with color .2 l r: print the total colorfulness on .
Input
The first line contains . Each of the next lines is 1 l r x or 2 l r.
Output
For every type-2 operation, print the total colorfulness on its own line.
Subtasks
-
Subtask 1 (20%): n,m≤30; all other conditions are unchanged.
-
Subtask 2 (30%): n,m≤3000; all other conditions are unchanged.
-
Subtask 3 (50%): full constraints:
-
-
-
Examples
Input
3 3
1 1 2 4
1 2 3 5
2 1 3
Output
8
Explanation
After painting positions 1..2 with color 4, colorfulness is [3,2,0]. Painting positions 2..3 with color 5 changes it to [3,3,2], whose sum is 8.