You have a bunch of triangular regions that tessellate an infinite 2D plane. The tesselation is defined as follows (see the diagram for a better understanding):
Recall that Euler's formula states that for real . First, draw a vertex at on the complex plane for all integers .
Then for every three vertices from the step above forming an equilateral triangle with side length 1, draw the edges forming its border. Additionally, draw a vertex at the center of the triangle and edges from the center of the triangle to each of three outer vertices.
You are given () input points, each of which lies strictly within some region (i.e., not on any vertex or edge). For any pair of the input points, define the distance between them to be the smallest number of edges crossed when drawing a path from one point to the other that doesn't pass through any vertex.
Output the sum of all pairwise distances between the input points.
输入格式
The first line contains (), the number of independent tests. Each test is specified as follows:
The first line contains .
The next lines each contain three integers , , and () representing a point at on the complex plane ( being a small positive number).
It is guaranteed that the sum of over all tests doesn't exceed .
输出格式
For each test, output the sum of all pairwise distances on a new line.