F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Problem D

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1    Accepted Submission(s): 1


Problem Description
In Warcraft III, Destroyer is a large flying unit that must consume magic to sustain its mana. Breaking free of the obsidian stone that holds them, these monstrous creatures roar into battle, swallowing magic to feed their insatiable hunger as they move between battles and rain destruction down upon their foes. Has Spell Immunity. Attacks land and air units.


The core skill of the Destroyer is so called Devour Magic, it takes all mana from all units in a area and gives it to the Destroyer.

Now to simplify the problem, assume you have n units in a line, all unit start with 0 mana and can increase to infinity maximum mana. All unit except the Destroyer have mana regeneration 1 in per unit time.

The Destroyer have m instructions t l r, it means, in time t, the Destroyer use Devour Magic on unit from l to r. We give you all m instructions in time order, count how many mana the Destroyer have devour altogether.
 

Input
The first line contains one integer T, indicating the test case. For each test case, the first contains two integer n, m(1 ≤ n, m ≤ 105). The the next m line each line contains a instruction t l r.(1 ≤ t ≤ 105, 1 ≤ l ≤ r ≤ n)
 

Output
For each test case, output the conrespornding result.
 

Sample Input
1 10 5 1 1 10 2 3 10 3 5 10 4 7 10 5 9 10
 

Sample Output
30
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2025 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2025-03-29 00:37:24, Gzip enabled