This page is still under construction.

Parts of this page are still being built. What you see may change.

Rockets

Time limit1sMemory limit128 MB

Summary
Match the n red points to the n white points with non-crossing segments so the total Euclidean length is minimum, and report the matching.
Level

Hard8 of 10

Topics
Dynamic programming, Divide and conquer, Geometry, Sorting
Solved
No attempts yet

Problem

A two dimensional map holds two sets of nn points each, RR and WW. No three points of R∪WR \cup W lie on one line. Surface to surface rockets stand on the points of RR, and the targets to destroy stand on the points of WW. A rocket flies only in a straight line, every rocket destroys exactly one target, and every target is hit by exactly one rocket.

No two trajectories may cross. Among the assignments that respect this, find the one whose total flight distance ∑i=1n∣riwki∣\sum_{i=1}^{n} |r_i w_{k_i}| is the smallest. Here ∣pq∣|pq| is the Euclidean distance between pp and qq, and wkiw_{k_i} is the target destroyed by rocket rir_i. The input guarantees that exactly one of the n!n! assignments reaches the smallest total flight distance, so the answer is unique.

Input

The first line contains the size nn of both RR and WW (1≤n≤2001 \le n \le 200).

Each of the next 2n2n lines contains the coordinates xx and yy of one point of the map, separated by a single space (−10000≤x,y≤10000-10000 \le x, y \le 10000). The first nn of those lines are the points of RR, the last nn are the points of WW. Line i+1i+1 holds rir_i and line i+n+1i+n+1 holds wiw_i (1≤i≤n1 \le i \le n). All 2n2n points are distinct and no three of them lie on one line.

Output

Print nn lines. Line ii contains the index kik_i of the target that rocket rir_i destroys.

Examples3

  1. Example 1

    Input
    4
    0 0
    1 5
    4 2
    2 6
    1 2
    5 4
    4 5
    3 1
    
    Expected output
    1
    2
    4
    3
    
  2. Example 2

    Input
    1
    -10000 -10000
    10000 10000
    
    Expected output
    1
    
  3. Example 3

    Input
    2
    0 0
    2 1
    1 1
    9 3
    
    Expected output
    1
    2