Under construction

Still being built. Things may change

Kingdom Partitioning

Time limit2sMemory limit128 MB

Summary
Simulate a sweep of vertical lines where each remaining kingdom's threshold crossing position is found via circle-area integration and the smallest threshold is served each round.
Level

Medium6 of 10

Topics
Geometry, Simulation, Greedy
Solved
No attempts yet

Problem

The Kingdom of Qari has fallen, and nn other kingdoms are dividing its land. Each of them values a different part of Qari. Napaj wants open ground to settle on, while Acirema cares only about the oil fields.

Every kingdom marks the land it wants as a union of circles that do not overlap. Kingdom ii is content when the land it receives holds at least 1/n1/n of the area it marked.

The council cuts Qari with n−1n-1 vertical lines, that is, lines parallel to the yy axis. The lines split the land into nn strips, and each strip goes to one kingdom. The council draws the lines from left to right by the following rule.

Let xx be the position of the last line drawn, and let xx be at minus infinity before the first line. For every kingdom ii that holds no strip yet, take the smallest position xi≥xx_i \ge x such that the strip between xx and xix_i holds at least 1/n1/n of the area kingdom ii marked. The council gives that strip to the kingdom with the smallest xix_i, draws the line at xix_i, and repeats with the remaining kingdoms. The kingdom left at the end takes everything to the right of the last line.

If several kingdoms share the smallest xix_i, the kingdom with the smaller number is served first. Two positions that differ by less than 10−910^{-9} count as the same position.

This rule always serves all nn kingdoms, and every one of them ends up content. Print the order in which the kingdoms are served.

Input

The first line contains an integer nn (1≤n≤301 \le n \le 30), the number of kingdoms dividing Qari. Then follow nn sections, one per kingdom, in the same order as the kingdom numbers.

The first line of the ii-th section contains an integer mim_i (1≤mi≤301 \le m_i \le 30), the number of circles marked by kingdom ii. Each of the next mim_i lines contains three integers xx, yy and rr (−1000≤x,y≤1000-1000 \le x, y \le 1000; 1≤r≤10001 \le r \le 1000), the coordinates of the center of one circle and its radius. Circles inside one section do not overlap, but they may touch. Circles marked by different kingdoms may overlap in any way.

Output

Print nn integers on one line, separated by single spaces: the numbers of the kingdoms in the order they receive their strips, from left to right.

Note

The picture shows the circles marked in the first example. Kingdom 1 marked the two circles labeled 1' and 1'', and kingdom 2 and kingdom 3 both marked the circle labeled 2 and 3. The dashed lines are one fair division of the land, but not the division the council draws here, because the council only uses lines parallel to the yy axis.

Kingdom 1 marked 8π8\pi in total and needs 8π/38\pi/3, which it reaches at x≈0.5299x \approx 0.5299, inside its left circle. Kingdom 2 and kingdom 3 each marked 4π4\pi and need 4π/34\pi/3, which they reach at x≈3.4701x \approx 3.4701. Kingdom 1 therefore takes the first strip. Kingdom 2 and kingdom 3 are then tied, so the smaller number goes first, and kingdom 3 keeps everything to the right of the second line, two thirds of its circle.

Examples3

  1. Example 1

    Input
    3
    2
    0 0 2
    7 0 2
    1
    4 0 2
    1
    4 0 2
    
    Expected output
    1 2 3
    
  2. Example 2

    Input
    1
    1
    0 0 5
    
    Expected output
    1
    
  3. Example 3

    Input
    2
    1
    0 0 1
    1
    -5 0 1
    
    Expected output
    2 1