Icy Itinerary
문제
It is a harsh and cold winter, in a town consisting of houses. Everybody is asleep in the early morning hours. The snow lies deep on the ground, except on the roads that connect some pairs of houses. Only Thomas is awake.
Thomas the mailman needs to deliver mail to each of the houses in the town. The houses are numbered from to . Thomas will start in his own house (house ), and then visit all the other houses in some order. He can use a bicycle to get between two houses connected by a road, and he can use skis if there is no road between the houses. But it is not possible to use skis on roads and the bicycle outside of roads. Switching between bicycle and skis is tedious, so Thomas would like to do this at most once.
Your task is to find an ordering of the houses so that , and there is at most one index () such that either
- and are connected by a road, but and are not, or
- and are not connected by a road, but and are.
In other words, the sequence starts at and switches between using roads and non-roads at most once.
입력
The first line contains two integers , (, ), the number of houses and the number of roads.
The next lines each contain two integers (), meaning that and are connected by a road. The roads can be used in both directions, and all the unordered pairs are distinct.
There exists a valid ordering for every case in the input.
출력
Print integers on one line, the order in which to visit the houses.
Remember that the first number should be .
예제
예제 1
4 4 1 2 1 3 1 4 3 4
1 4 3 2
예제 2
5 0
1 2 3 4 5