At the first stage of the Revolution Football Cup, all the teams are divided
into groups and play according to the all-play-all system. The organizers of
the tournament ask you to help them form the groups.
The teams should be divided into g groups, t teams in each group. The
teams have been distributed to t pots, g teams in each pot. In the
first pot there are the strongest teams, in the second pot there are teams
that are a bit less stronger, and so on. In the last pot there are the
weakest teams. It is required to form groups so that there would be exactly
one team from each pot in each group. The organizers also want all t teams
in each group to represent different political parties.
The first line contains the integers g and t separated with a
space (2 ≤ g, t ≤ 100). The following lines describe the pots.
Each line contains the name of a team and the name of the party it represents.
These names are separated with a space. The descriptions of pots are separated
with an empty line. The names of teams and parties consist of lowercase English
letters, and their lengths are in the range from 1 to 10. The names of
all teams are different.
If it is impossible to divide the teams into groups as required, output one
line containing the word “No”. Otherwise, output “Yes” and then
the description of g groups. Each group is described by the names
of t teams that are in this group, each name in a separate line.
The description of each group should be preceded by an empty line.
If there are several answers, output any of them.
Problem Author: Magaz Asanov
Problem Source: NEERC 2010, Eastern subregional contest