QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓
Statistics
problem_11535_1.jpg

There are $N$ cities numbered from $1$ to $N$, the $i$-th of which is at coordinates $(x_i, y_i)$.

Busy Beaver wants to start at city $1$, visit every city exactly once, and return to city $1$.

To go from city $i$ to city $j$, it takes $|x_i - x_j + y_i - y_j|$ seconds. Find the minimum number of seconds for Busy Beaver to complete his trip.

Input

The first line contains a single integer $T$ ($1 \leq T \leq 10^4$)~--- the number of test cases.

The first line of each test case contains a single integer $N$ ($2 \leq N \leq 2 \cdot 10^5$)~--- the number of cities.

The $i$-th of the next $N$ lines of each test case contains two integers $x_i$ and $y_i$ ($-10^9 \leq x_i, y_i \leq 10^9$)~--- the coordinates of the $i$-th city.

The sum of $N$ across all test cases does not exceed $2 \cdot 10^5$.

Output

For each test case, output a single integer~--- the minimum number of seconds needed for Busy Beaver to complete his trip.

Example

Input

3
5
0 0
-2 0
1 2
-1 3
0 1
3
0 0
1 4
3 4
2
-1 9
8 -4

Output

10
14
8

Explanation

In the first test case, we can take the path $1 \xrightarrow{3\,\text{seconds}} 3 \xrightarrow{1\,\text{second}} 4 \xrightarrow{1\,\text{second}} 5 \xrightarrow{3\,\text{seconds}} 2 \xrightarrow{2\,\text{seconds}} 1$ which takes $3+1+1+3+2=10$ seconds.

problem_11535_1.png

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.