Travel
Little Y is an OIer who loves traveling. She plans to visit every city in country X.
Little Y has learned that there are $m$ bidirectional roads between the $n$ cities in country X. Each bidirectional road connects two cities. There are no two roads connecting the same pair of cities, and there are no roads connecting a city to itself. Furthermore, it is possible to reach any other city from any city by traveling along these roads. Little Y can only travel between cities using these roads.
Little Y's travel plan is as follows: she chooses an arbitrary city as the starting point, and then starts from the starting point. Each time, she can choose a road connected to the current city to move to a city she has not visited before, or backtrack to the previous city along the road she used to visit the current city for the first time. When Little Y returns to the starting point, she can choose to end the trip or continue traveling. It should be noted that Little Y requires that every city must be visited during the trip.
To make her trip more meaningful, Little Y decides to record the ID of each city as she arrives at it (including the starting point). She knows this will form a sequence of length $n$. She hopes that this sequence will be lexicographically as small as possible. Can you help her?
For two sequences $A$ and $B$ of length $n$, we say sequence $A$ is lexicographically smaller than $B$ if and only if there exists an integer $x$ such that the following conditions are met: For any $1 \le i < x$, the $i$-th element $A_i$ of sequence $A$ is equal to the $i$-th element $B_i$ of sequence $B$. The value of the $x$-th element of sequence $A$ is smaller than the value of the $x$-th element of sequence $B$.
Input
The input contains $m+1$ lines. The first line contains two integers $n, m$ ($m = n-1$ or $m = n$), separated by a space.
The next $m$ lines each contain two integers $u, v$ ($1 \le u, v \le n$), representing a road between city $u$ and city $v$, separated by a space.
Output
The output contains one line with $n$ integers, representing the lexicographically smallest sequence. Adjacent integers are separated by a space.
Examples
Input 1
6 5 1 3 2 3 2 5 3 4 4 6
Output 1
1 3 2 5 4 6
Input 2
6 6 1 3 2 3 2 5 3 4 4 5 4 6
Output 2
1 3 2 4 5 6
Input 3
(See travel/travel3.in and travel/travel3.ans in the provided directory)
Note: This example satisfies $m = n - 1$.
Input 4
(See travel/travel4.in and travel/travel4.ans in the provided directory)
Note: This example satisfies $m = n$.
Constraints
For 100% of the data and all examples, $1 \le n \le 5000$ and $m = n - 1$ or $m = n$.
The constraints for different test cases are as follows:
| Test Case ID | $n$ | $m$ | Special Property |
|---|---|---|---|
| 1, 2, 3 | 10 | None | |
| 4, 5 | 100 | None | |
| 6, 7, 8 | 1000 | At most two roads connected to each city | |
| 9, 10 | 1000 | None | |
| 11, 12, 13 | 5000 | At most three roads connected to each city | |
| 14, 15 | 5000 | None | |
| 16, 17 | 10 | None | |
| 18, 19 | 100 | None | |
| 20, 21, 22 | 1000 | At most two roads connected to each city | |
| 23, 24, 25 | 5000 | None |