Race Map Labeling

Simulate the smallest-first label-flipping process on the graph and print every place with its final label.

Medium5SimulationGraphNo attempts yetTime limit2sMemory limit256 MB

Problem

The organizing committee of a motorcycle race labels the contest map. The map has nn places numbered 00 through n1n-1. Every road is bidirectional and joins two different places.

Each place gets the label 00 for regular or 11 for service. If did_i roads reach place ii, then at most di/2\lfloor d_i / 2 \rfloor of its neighbors may carry the same label as place ii. Several labelings usually satisfy that rule, so only the labeling produced by the following procedure counts as correct.

  1. Give every place the label 00.
  2. While some place breaks the rule, take the smallest-numbered such place and flip its label: 00 becomes 11, and 11 becomes 00.
  3. Repeat step 2 until no place breaks the rule.

Each flip raises the number of roads whose two ends carry different labels by at least 11, so the procedure always stops after finitely many flips.

Input

The first line contains the number of places nn. (1n10001 \le n \le 1000)

Each of the next nn lines describes one place, line ii describing place ii. (i=0,1,,n1i = 0, 1, \dots, n-1) A line has this form.

number_of_neighbors: neighbor1 neighbor2 ... neighborm

number_of_neighbors is the number of roads reaching place ii, followed by the numbers of the neighboring places separated by spaces. The line 2: 1 2 means two neighbors, numbered 11 and 22.

No road joins a place to itself, and two places are joined by at most one road. If bb appears in the neighbor list of place aa, then aa appears in the neighbor list of place bb. The line of a place with no neighbor ends right after the colon.

Output

Print nn on the first line. Then print nn lines, one per place starting from place 00, each carrying the label the procedure produced. A line has this form.

label number_of_neighbors: neighbor1 neighbor2 ... neighborm

label is 00 for a regular place and 11 for a service place. Print the neighbor list in the order it was given in the input. Separate tokens with one space, and put the colon directly after number_of_neighbors. The line of a place with no neighbor ends right after the colon.