Palace

Time Limit: 4000ms
Memory Limit: 262144KB
This problem will be judged on HDU. Original ID: 5721
64-bit integer IO format: %I64d      Java class name: Main

Description

The last trial Venus imposes on Psyche is a quest to the underworld. She is to take a box and obtain in it a dose of the beauty of Prosperina, queen of the underworld.

There are $ n $ palaces in the underworld, which can be located on a 2-Dimension plane with $ (x, y) $ coordinates (where $ x, y $ are integers). Psyche would like to find the distance of the closest pair of two palaces. It is the password to enter the main palace.

However, the underworld is mysterious and changes all the time. At different times, exactly one of the $ n $ palaces disappears.

Psyche wonders what the distance of the closest pair of two palaces is after some palace has disappeared.

Print the sum of the distance after every single palace has disappeared.

To avoid floating point error, define the distance $ d $ between palace $ (x_1, y_1) $ and $ (x_2, y_2) $ as $ d = (x_1 - x_2) ^ 2 + (y_1 - y_2) ^ 2 $.

Input

The first line of the input contains an integer $ T $ $ (1 \le T \le 5) $, which denotes the number of testcases.

For each testcase, the first line contains an integers $ n $ $ (3 \le n \le 10 ^ 5) $, which denotes the number of temples in this testcase.

The following $ n $ lines contains $ n $ pairs of integers, the $ i $-th pair $ (x, y) $ $ (-10 ^ 5 \le x,y \le 10 ^ 5) $ denotes the position of the $ i $-th palace.

Output

For each testcase, print an integer which denotes the sum of the distance after every single palace has disappeared.

Sample Input

1
3
0 0
1 1
2 2

Sample Output

12

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .