Universal Cup Judging System

Universal Cup

Limite de temps : 2.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓
Statistiques

There are $N$ points $p_1, p_2, \dots, p_N$ on a two-dimensional plane.

Point $p_i$ is located at $(X_i, Y_i)$. No two points share the same coordinates.

Construct one permutation $q = (q_1, q_2, \dots, q_N)$ of the sequence of points $p = (p_1, p_2, \dots, p_N)$ that satisfies the following condition, or determine that it is impossible.

  • For all $1 \le i \le N - 2$, the three points $q_i, q_{i+1}, q_{i+2}$ are either collinear or form a counterclockwise turn in this order.
    • More precisely, let the coordinates of $q_i$ be $(x_i, y_i)$. Then the following must hold: $(x_{i+1} - x_i)(y_{i+2} - y_{i+1}) - (y_{i+1} - y_i)(x_{i+2} - x_{i+1}) \ge 0$.

Solve this problem for $T$ test cases.

Input

The input is given in the following format:

T
case1
case2
:
caseT

Each test case is given in the following format:

N
X1 Y1
X2 Y2
:
XN YN
  • $1 \le T \le 100$
  • $3 \le N \le 3000$
  • $0 \le X_i, Y_i \le 10^9$
  • $(X_i, Y_i) \ne (X_j, Y_j)$ ($i \ne j$)
  • The sum of $N$ over all test cases does not exceed $3000$
  • All input values are integers

Output

Print $T$ lines.

For the $i$-th line, if there is no $q$ satisfying the condition for the $i$-th test case, print $-1$.

Otherwise, let $q = (p_{r_1}, p_{r_2}, \dots, p_{r_N})$. Output $r_1, r_2, \dots, r_N$ in this order, separated by spaces.

If multiple valid answers exist, you may output any of them.

Example

Input 1

1
9
2 4
2 3
2 2
1 1
4 4
4 3
5 2
5 1
6 5

Output 1

6 9 2 3 5 1 8 7 4

Note

problem_17421_1.png

Figure 1: Explanation for the example.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1485EditorialOpen题解jianglyView
#1343EditorialOpen题解MilmonView

Discussions

About Discussions

The discussion section is only for posting: 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.
  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.