Codeforces Round 812 (Div. 2) |
---|
Finished |
You are living on an infinite plane with the Cartesian coordinate system on it. In one move you can go to any of the four adjacent points (left, right, up, down).
More formally, if you are standing at the point $$$(x, y)$$$, you can:
There are $$$n$$$ boxes on this plane. The $$$i$$$-th box has coordinates $$$(x_i,y_i)$$$. It is guaranteed that the boxes are either on the $$$x$$$-axis or the $$$y$$$-axis. That is, either $$$x_i=0$$$ or $$$y_i=0$$$.
You can collect a box if you and the box are at the same point. Find the minimum number of moves you have to perform to collect all of these boxes if you have to start and finish at the point $$$(0,0)$$$.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases.
The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of boxes.
The $$$i$$$-th line of the following $$$n$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$-100 \le x_i, y_i \le 100$$$) — the coordinate of the $$$i$$$-th box. It is guaranteed that either $$$x_i=0$$$ or $$$y_i=0$$$.
Do note that the sum of $$$n$$$ over all test cases is not bounded.
For each test case output a single integer — the minimum number of moves required.
340 -21 0-1 00 230 2-3 00 -110 0
12 12 0
In the first test case, a possible sequence of moves that uses the minimum number of moves required is shown below.
In the second test case, a possible sequence of moves that uses the minimum number of moves required is shown below.
In the third test case, we can collect all boxes without making any moves.
Name |
---|