Time limit
1s
Memory limit
128 MB
A meeting organizer wants to divide the attendees into one or more committees based on which attendees know each other. The committees must satisfy the following rules.
Therefore, each committee is exactly one group of attendees connected through the acquaintance relationships.
Each committee must choose one representative. During the meeting, only representatives may speak, so each attendee must pass their opinion to the representative of their committee. An attendee can pass an opinion only to someone they know directly, so the opinion may need to pass through several people.
For an attendee, define the communication time as the minimum number of people the opinion must pass through to reach the representative. For every committee, choose a representative so that the maximum communication time among all attendees in that committee is as small as possible.
Write a program that finds the representative of each committee.
For example, suppose attendees 1, 2, and 3 form one committee, and the acquaintance pairs are 1-2 and 2-3. Choosing attendee 2 as the representative is best. If attendee 1 or 3 is the representative, the attendee at the opposite end must pass the opinion through one person, but if attendee 2 is the representative, both other attendees can pass their opinions directly.
The first line contains the number of attendees N. Attendees are numbered from 1 to N, and N is at most 100.
The second line contains the number of acquaintance relationships M. Each of the next M lines contains two attendee numbers that know each other.
Print the number of committees K on the first line.
Then print K lines, one representative number per line, in increasing order. If more than one attendee can be a representative for the same committee, printing any one of them is acceptable.