Delivery

No attempts yetTime limit1sMemory limit128 MB

Problem

Some parcels have to be delivered. Each parcel has its own starting point and destination, and every parcel is the same size. The delivery man Jim carries at most one parcel at a time, and he does not put down the parcel he is carrying on his way. After delivering all the parcels, Jim has to return to the position he started from. Jim wants to make the distance he moves as small as possible.

The city Jim works in consists of a single straight road. The leftmost position of the road is Jim's starting point, and every parcel's starting point and destination lie on the road. All the parcel information is given before Jim starts to move, and the information of one parcel is nothing more than its starting point and its destination. Jim delivers all the parcels alone.

The figure above shows a case with two parcels, one to be delivered from 11 to 44 and the other from 33 to 66. 00 is Jim's starting point, and the other numbers are distances from 00 to the corresponding points. The figure below shows an optimal solution. Jim first moves to 44, delivering the parcel at 11 to 44. Then he moves back to position 33 and delivers the parcel at 33 to 66. Finally he moves back to his starting point 00. The total distance he moves is 4+1+3+6=144+1+3+6=14, which is optimal for this case.

Input

Your program is to read from standard input. The first line holds the number of test cases TT (1T201 \le T \le 20).

The first line of each test case holds the number of parcels AA (1A500001 \le A \le 50\,000). Each of the next AA lines holds the starting point BB (1B1000001 \le B \le 100\,000) and the destination CC (1C1000001 \le C \le 100\,000) of one parcel.

Output

Your program is to write to standard output. For each test case, print the minimum moving distance of Jim on its own line.