SP2658 WAR - Art of War

Description

The _Warring States Period_ (473-22l BC) refers to the centuries of turmoil following the Spring and Autumn Period. China was divided into many little kingdoms that were constantly fighting with each other. Unlike in previous ages, when chivalry played an important role in battles and the states fought mostly for balance of power or to resolve disputes, in this period the aim of battle was to conquer and completely annihilate the other states. Eventually seven states, known as the ``Seven Great Powers'' rose to prominence: Qi, Chu, Yan, Han, Zhao, Wei, and Qin. After numerous alliances and counter-alliances, Qin defeated all the other states one by one, putting an end to the Warring States Period. You are given a map that shows the position of the capital for each state, and the borders between the states as a series of line segments. Your job is to determine which states were fighting with each other. This is pretty easy to determine - if two states had a common border, then they were fighting.

Input Format

The input contains several blocks of test cases. Each case begins with a line containing two integers: the number 1

Output Format

For each test case, you have to output _n_ lines that describe the enemies of the _n_ states (recall that if two states share a border, then they are enemies). Each line begins with an integer, the number _x_ of enemies the given state has. This number is followed by _x_ numbers identifying the enemies of the state. These numbers are between 1 and _n_ and number 1 refers to the first capital appearing in the input, number _n_ refers to the last.