## #1640 City Horizon

13  1 s   128 MB

## Description

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 Ai through Bialong the horizon (1 ≤ Ai < Bi ≤ 1,000,000,000) and has height Hi (1 ≤ Hi ≤ 1,000,000,000). Determine the area, in square units, of the aggregate silhouette formed by all N buildings.

## Input

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  AiBi, and Hi .

## Output

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

### Sample Output

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

USACO