제출: 109 통과: 21

[제출] [채점기록] [묻고답하기]

Farmer John has taken his cows on a trip to the city! As the sun sets, the cows gaze at the city horizon and observe the beautiful silhouettes formed by the rectangular buildings.

The entire horizon is represented by a number line with *N* (1 ≤ *N* ≤ 40,000) buildings. Building *i*'s silhouette has a base that spans locations *A _{i}* through

Input consists of several test cases. The first line of whole input contains a single integer *T*, the number of test cases.

Then *T* test cases follow. The first line of each test case contains a single integer *N*. Then *N* lines follow, describing each building with three space-separated integers *A _{i}*,

For each test case, write a single line which contains the total area, in square units, of the silhouettes formed by all *N* buildings.

```
1
4
2 5 1
9 10 4
6 8 2
4 6 3
```

`16`