PivotOJ

Hamiltooonian Hike

시간 제한: 2000ms메모리 제한: 1024MB출처: BAPC 2021BOJ 23382

문제

Alice loves hiking. She often travels through forests and over mountains for several days, bringing only a backpack. For next year's summer, she decided to travel to a beautiful area which contains a large number of cabins: places where hikers can lay down a sleeping bag and stay for the night. These cabins are connected by hiking trails, paths along the scenery in the area which lead to a next cabin.

Alice's plan is to perform a multi-day hike. Every day, she will walk along the trails to a new cabin to spend the night. She can walk up to three trails in one day---walking four trails is too exhausting. In order to experience as much of the cabins as possible, Alice has decided that she wants to sleep in every cabin at least once. However, the summer has a limited number of days: she does not have the time to visit a cabin multiple times.

Alice has noticed that this requires careful planning of her hike and wonders how to find such a route. Determine which cabin Alice should walk to for every day. Figure H.1 shows a possible route for the second sample case.

Figure H.1: The input and a possible route (dashed red arrows) for the second sample case.

입력

The input consists of:

  • One line containing two integers nn (2n21052\leq n\leq 2\cdot 10^5) and mm (1m21051\leq m \leq 2\cdot 10^5), the number of cabins and hiking trails.
  • mm lines each containing two integers x,yx,y (1x,yn1 \leq x,y \leq n, xyx \neq y), indicating that there is a hiking trail between cabins xx and yy.

It is guaranteed that every cabin is reachable from every other cabin. There is at most one hiking trail between any two cabins.

출력

Output the order in which Alice should visit the nn cabins.

You do not need to minimize the total number of hiking trails.

If there are multiple valid solutions, you may output any one of them.

예제

예제 1

입력
7 8
1 2
1 7
2 3
2 4
3 4
4 5
5 6
5 7
출력
1 4 2 5 7 6 3
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.