A woodworking shop has n wooden sticks. Each stick has a fixed length and weight. The sticks are processed by a machine one at a time. Before processing a stick, the machine may need some time to be prepared for that stick — this is called the setup time. The setup time is determined by the following rules.
You may process the sticks in any order. Find the minimum total setup time needed to process all of the sticks.
For example, suppose there are five sticks (4,9),(5,2),(2,1),(3,5),(1,4). Processing them in the order (1,4),(3,5),(4,9),(2,1),(5,2) needs a total setup time of 2 minutes, and this cannot be reduced any further, so the answer is 2.
The first line contains the number of test cases T.
Each test case consists of two lines. The first line contains the number of sticks n (1≤n≤5000). The second line contains l1 w1 l2 w2 … ln wn separated by spaces, where li and wi are the length and weight of the i-th stick. All of these values are integers not greater than 10000.
For each test case, print the minimum required setup time on its own line.