#abc373g. G - No Cross Matching

G - No Cross Matching

Score : 600600 points

问题陈述

在二维平面上有 2N2N 个点 P1,P2,,PN,Q1,Q2,,QNP_1, P_2, \ldots, P_N, Q_1, Q_2, \ldots, Q_N。点 PiP_i 的坐标是 (Ai,Bi)(A_i, B_i),点 QiQ_i 的坐标是 (Ci,Di)(C_i, D_i)。没有三个不同的点在同一条直线上。

确定是否存在一个排列 R=(R1,R2,,RN)R = (R_1, R_2, \ldots, R_N)(1,2,,N)(1, 2, \ldots, N) 满足以下条件。如果存在这样的 RR,请找出一个。

  • 对于从 11NN 的每个整数 ii,让线段 ii 是连接 PiP_iQRiQ_{R_i} 的线段。那么,线段 ii 和线段 jj (1i<jN)(1 \leq i < j \leq N) 永远不会相交。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

There are 2N2N points P1,P2,,PN,Q1,Q2,,QNP_1,P_2,\ldots,P_N, Q_1,Q_2,\ldots,Q_N on a two-dimensional plane. The coordinates of PiP_i are (Ai,Bi)(A_i, B_i), and the coordinates of QiQ_i are (Ci,Di)(C_i, D_i). No three different points lie on the same straight line.

Determine whether there exists a permutation R=(R1,R2,,RN)R = (R_1, R_2, \ldots, R_N) of (1,2,,N)(1, 2, \ldots, N) that satisfies the following condition. If such an RR exists, find one.

  • For each integer ii from 11 through NN, let segment ii be the line segment connecting PiP_i and QRiQ_{R_i}. Then, segment ii and segment jj (1i<jN)(1 \leq i < j \leq N) never intersect.

Constraints

  • 1N3001 \leq N \leq 300
  • 0Ai,Bi,Ci,Di50000 \leq A_i, B_i, C_i, D_i \leq 5000 (1iN)(1 \leq i \leq N)
  • (Ai,Bi)(Aj,Bj)(A_i, B_i) \neq (A_j, B_j) (1i<jN)(1 \leq i < j \leq N)
  • (Ci,Di)(Cj,Dj)(C_i, D_i) \neq (C_j, D_j) (1i<jN)(1 \leq i < j \leq N)
  • (Ai,Bi)(Cj,Dj)(A_i, B_i) \neq (C_j, D_j) (1i,jN)(1 \leq i, j \leq N)
  • No three different points lie on the same straight line.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN

A1A_1 B1B_1

A2A_2 B2B_2

\vdots

ANA_N BNB_N

C1C_1 D1D_1

C2C_2 D2D_2

\vdots

CNC_N DND_N

Output

If there is no RR satisfying the condition, print -1.

If such an RR exists, print R1,R2,,RNR_1, R_2, \ldots, R_N separated by spaces. If there are multiple solutions, you may print any of them.

Sample Input 1

3
0 0
2 4
4 2
0 2
2 0
4 4

Sample Output 1

2 1 3

The points are arranged as shown in the following figure.

By setting R=(2,1,3)R = (2, 1, 3), the three line segments do not cross each other. Also, any of R=(1,2,3)R = (1, 2, 3), (1,3,2)(1, 3, 2), (2,3,1)(2, 3, 1), and (3,1,2)(3, 1, 2) is a valid answer.

Sample Input 2

8
59 85
60 57
72 12
3 27
16 58
41 94
77 64
97 20
32 37
7 2
57 94
35 70
38 60
97 100
5 76
38 8

Sample Output 2

3 5 8 2 7 4 6 1