## Birthday Party

View as PDF

Points: 5
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Metabook, in its quest to be the app with the most features, has decided to add the option for a user to host a birthday party! On the user's birthday, they will have the option to invite everyone who has a closeness to them.

Metabook is a social media platform modelled with users as nodes. Users can be friended with other users, and this connection is bidirectional, with denoting a friendship between user and . Additionally, these users and connections form a tree, and so the closeness between users and is the distance of the shortest path between them (which is also the only non-repeating path). For this problem, all users are numbered from to , and in this scenario user is the one throwing the birthday party.

#### Input Specification

The first line contains two integers and , the number of users and the minimum closeness needed for a user to be invited

The next lines each contain two integers and , denoting a friendship between user and

#### Output Specification

The first line contains , the number of users who will be invited

The second line contains integers, the users who will be invited to user 's birthday party, output in increasing order

#### Sample Input

7 1
1 2
2 3
1 5
3 4
2 6
1 7

#### Sample Output

3
2 5 7

#### Sample Explanation

Nodes 2, 5, and 7 all have a distance of from node , so they will be invited.