Segment Tree - Multiple Update
World is getting more evil and it's getting tougher to get into the Evil League of Evil. Since the legendary Bad Horse has retired, now you have to correctly answer the evil questions of Dr. Horrible, who has a PhD in horribleness (but not in Computer Science). You are given an array of n elements, which are initially all 0. After that you will be given c commands. They are:
- 0 p q v - you have to add v to all numbers in the range of p to q inclusive, where p and q are two indexes of the array.
- 1 p q - print a line containing a single integer which is the sum of all the array elements between p and q inclusive.
The first line contains the number of test cases. Each test case starts with n (n ≤ 100 000) and c (c ≤ 100 000). After that you'll be given c commands in the format as mentioned above. It is known that 1 ≤ p, q ≤ n and 1 ≤ v ≤
Print the answers to the queries.
1 8 6 0 2 4 26 0 4 8 80 0 4 5 20 1 8 8 0 5 7 14 1 4 8