beecrowd | 1923

Rerisson and The Barbecue

By Gustavo Ribeiro, IFPB - Campina Grande BR Brazil

Timelimit: 1

After having a barbecue to celebrate the results of OPI (Paraíba’s Informatics Olympiad) with his friends, Rerisson wants to have another barbecue, this time a greater one. The goal of this barbecue is to meet new people. He will invite all the persons who have a degree of relationship to him (called g) of at most G. For example, consider ‘>’ as a direct relationship simbol.

Rerisson > Lucas

Rerisson > Jonathan

Lucas > Jonathan

Jonathan > Pedro

Pedro > Juan

Lucas > Juan

For this example, considering G = 1, just Lucas and Jonathan will be invite to the barbecue.

With the help of a social network, Rerisson knows all direct relashionships of everybody, but he’s busy preparing the barbecue. Could you help Rerisson decide which people will be invited to the great party?

Input

The first line of the input will contain two integers, 3 ≤ n ≤ 103 e 1 ≤ G ≤ 500, the quantity of relations to be considered and the maximum relashionship degree, respectively. Each of the next lines will contain two strings S and T, 1 ≤ |S|, |T| ≤ 20 composed by latin american letters only, describing a direct relashionship (The relashionship is mutual).

Output

Print the number of peoples that will be invited to the barbecue, following by their names in ascending lexicografical order.

Input Samples Output Samples

6 1

Rerisson Lucas

Rerisson Jonathan

Lucas Jonathan

Jonathan Pedro

Pedro Juan

Lucas Juan

2

Jonathan

Lucas

4 3

Rerisson Ordan

Ordan Gustavo

Rerisson Yean

Gustavo Yean

3

Gustavo

Ordan

Yean