Simple Polygon

Time limit1sMemory limit128 MB

Problem

You are given a set of points in the plane. Write a program that builds a polygon whose vertices are exactly these points. Every point in the set must be a vertex of the polygon, and no point outside the set may be used as a vertex. Moreover, no two distinct edges of the polygon may touch or cross, except at a vertex shared by two consecutive edges. In other words, the polygon must be simple.

The given points can always form such a simple polygon. No two points coincide, and the points are never all on a single straight line.

Input

The first line contains the number of test cases $c$ ($1 \le c \le 200$). Each test case is given on its own line. The first integer on that line is the number of points $n$ ($3 \le n \le 2000$), followed by the coordinates $x$ and $y$ of each point in order. Every coordinate is an integer between $-10000$ and $10000$, inclusive. The points are numbered $0$ to $n-1$ in the order they are given.

Output

For each test case, print on one line a permutation of the integers $0$ to $n-1$, separated by single spaces. The permutation gives the order in which the points are connected, and connecting them in that order must form a simple polygon.

Because several simple polygons may be possible, output the single order defined by the following deterministic rule.

  1. Pick the anchor: the point with the smallest $y$-coordinate; if several points share it, the one with the smallest $x$-coordinate.
  2. Sort the remaining points counterclockwise (by increasing angle) by the direction of the vector from the anchor to each point.
  3. Points with the same direction angle (those collinear with the anchor) are ordered by increasing distance from the anchor, except the group sharing the largest angle, which is ordered by decreasing distance.
  4. Print the anchor's index first, then the indices of the remaining points in the order determined above.

The order obtained this way always forms a simple polygon.