Eccentric Excursion
시간 제한6초메모리 제한2048 MB
도시 n개가 트리로 연결되어 있을 때, 트리 간선과 정확히 k개의 비트리 간선(항공편)을 사용해 모든 도시를 한 번씩 방문하는 순열 중 사전순으로 가장 작은 것을 구하거나 불가능하면 -1을 출력한다.
문제
Eddy is planning a cross-country trip across different cities. There are roads connecting the cities. Each road connects two cities and is bidirectional. The roads are laid out such that it is possible to travel between any two cities using only roads.
Eddy wants to plan a trip so that he visits each city exactly once. He may start or end at any city. It might not be possible to visit each city exactly once using only roads. Luckily, Eddy can take a flight between any two cities that aren't directly connected by a road. Eddy would like to take exactly flights during his trip.
Help Eddy plan his trip.
입력
The first line contains two integers () where is the number of cities Eddy is visiting and is the number of flights Eddy would like to take.
The next lines each contain two integers () indicating that there is a road between cities and . It is guaranteed it is possible to travel from any city to any other city only using roads.
출력
Output integers that specify the sequence of cities that Eddy shall visit in order. The sequence must visit each city exactly once and use exactly flights. If there are multiple possible itineraries, output the lexicographically smallest sequence. If there is no possible itinerary, output .