Under construction

Still being built. Things may change

Juggle Struggle: Part 1

Memory limit1024 MB

Summary
Given 2N points with no three collinear, pair them up so that every two segments between pairs cross.
Level

Medium6 of 10

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

Problem

The first two paragraphs (not counting this one) of this problem and 'Juggle Struggle: Part 2' are identical. The problems can otherwise be solved independently, so you do not need to read or solve one to read or solve the other.

As manager of the Graceful Chainsaw Jugglers group, you have decided to spice up the show. Instead of having each juggler toss their own chainsaws alone, you want them to form pairs, with each pair throwing chainsaws back and forth to each other. In this new performance, 2×N2 \times N jugglers will be on stage at the same time, arranged into NN pairs, with each juggler in exactly one pair.

The chainsaws juggled by different pairs are at risk of collision if the pairs' paths cross. The stage is a two-dimensional plane. The straight line segment connecting the two jugglers in a pair is that pair's juggling path. When two juggling paths intersect, the chainsaws of those two pairs are at risk of collision. The positions of the jugglers and their pairings together form an arrangement. An arrangement is magnificent if every two pairs have chainsaws that are at risk of collision.

You found a magnificent arrangement and wrote down the juggler positions and pairings on a piece of paper. A bad chainsaw throw then cut the paper in half, and the half with the pairings was lost. The stage decorations were already designed around the juggler positions, so those positions cannot change. The show debuts in a few hours. Given every juggler's position on the two-dimensional stage, find a pairing that yields a magnificent arrangement.

Input

The first line of the input gives the number of test cases, TT. TT test cases follow. Each test case starts with one line containing a single integer NN, the number of pairs. Then 2×N2 \times N lines follow. The ii-th of these lines contains two integers XiX_i and YiY_i, the coordinates of the ii-th juggler.

Output

For each test case, output one line containing Case #x: j1 j2 ... j2×N, meaning jugglers ii and jij_i are paired together for every ii. Note that jji=ij_{j_i} = i for every ii.

Limits

  • −109≤Xi≤109-10^9 \le X_i \le 10^9 for all ii.
  • −109≤Yi≤109-10^9 \le Y_i \le 10^9 for all ii.
  • No three juggler positions are collinear. This also means no two jugglers share a position.
  • At least one pairing exists that yields a magnificent arrangement.

Hint

In Sample Case #1, the jugglers' positions form a square. The only valid solution pairs jugglers 1 and 3, and pairs jugglers 2 and 4.

Examples1

  1. Example 1

    Input
    3
    2
    -1 -1
    -1 1
    1 1
    1 -1
    3
    1 2
    2 1
    2 3
    3 1
    3 3
    4 2
    3
    7 1
    1 1
    7 2
    5 5
    3 5
    1 2
    
    Expected output
    Case #1: 3 4 1 2
    Case #2: 6 5 4 3 2 1
    Case #3: 5 4 6 2 1 3