Content： 正體->简体

Connect-the-dots is a new popular game on iPad. At the onset of the game, n random numbers of dot are placed on the screen. The ith dot has the coordinate of (xi, yi). The player must connect all the dots via straight line-segments so that no dot is isolated. The game is scored as follows:

Sum of integral length of edge(i, j) for all line-segments i-j.

The integral length of edge (i, j) is computed as |yi-yj|+|xi-xj|. Write a program to compute and output the minimum possible score.

Input：

First line contains an integer indicating the number of test cases to follow. For each test case, coordinates of random number of dots are given. The coordinate of “-1 -1” indicates the end of a test case. There are can be at most 5000 dots. The coordinates are all positive integer between 0 and 1000.

Output：

For each test case, output the minimum score possible when all the dots are inter-connected.

Sample Input：

若題目沒有特別說明，則應該以多測資的方式讀取，若不知如何讀取請參考 a001 的範例程式。2

1 1 2 2 3 3 -1 -1

0 1 1 0 1 1 0 0 -1 -1

Sample Output ：

4

3

### Recently Asked Questions

- Which of the following fraudulent activities most likely could be perpetrated due to the lack of effective internal control over the revenue cycle ?

- CPA-02014 PII Nov 93 # 38 Adapted Page 32 Poole , 45 years old and unmarried , is in the 15 % tax bracket . He had 2002 adjusted gross income of $ 20,000 . The

- Which of the following is descriptive of financial-based responsibility accounting ?