Rajat and Classes

1

1 votes
Problem

Rajat is the newly appointed principal of the prestigious FALTU college. As a principal, he has the responsibility to ensure proper functioning of the college.
For this, he need to select some student representatives for the Students Welfare Council.
There are N students in the college, numbered from 1 to N.
Also, there exist M direct friendships between a pair of students in the college. If A and B are direct friends, such a friendship will denoted by (A, B).

The friendship is Symmetric. This means that if A is a friend of B then B is a friend of A as well.

Besides, friendship is Transitive. This means that if A is a friend of B AND B is a friend of C, then A and C are also friends. Lets call such friends the indirect friends

Also B is said to be true friend of A if A and B are direct friends i.e. there exist a pair (A,B).
Being an experienced principal and a wise diplomat, he don't wants to select representatives in a way such that two friends(direct or indirect), become the representative simultaneously.
Also he wants the maximum number of representatives to be selected for the Council.

In order to avoid conflict among friends, he wants to select the student having the maximum number of true friends as the representative.
Your task is to help him find the maximum number of representatives that can be selected and the id of the selected representatives.
If multiple solutions are possible, print the one having minimum ids of representatives selected.

Input Format:

Input will begin by 2 integer N and C, representing the number of students in college and the number of friendship pairs. The following C lines contain 2 integers A and B separated by a space, denoting A is a friend of B.

Output Format:

Print a single integer R, the number of representatives, in the first line.
Print R integers, representing each representative, in the next line separated by single space.(Sort these integers before printing).

Scoring Criteria:

30 Points: 2<=N<100 and 1<=A,B<=N and 1<=C<=5000
50 Points: 2<=N<=100000 and 1<=A,B<=N and 1<=C<=1000000

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?