You are given $n$ points with integer coordinates in the plane. Determine whether it is possible to build a simple rectilinear polygon whose vertices are exactly these points.
A rectilinear polygon satisfies all of the following:
Every given point must be used as a vertex. If such a polygon exists, output its perimeter (the sum of the lengths of all edges); otherwise output $-1$.
The first line contains an integer, the number of test cases.
Each test case begins with an integer $n$ ($4 \le n \le 100000$), the number of points, followed by $n$ pairs of integers giving the $x$ and $y$ coordinates of the points.
For each test case output a single line. If a valid rectilinear polygon through the given points exists, output its perimeter as an integer; otherwise output $-1$.