Breadth-First Traversal


Submit solution

Points: 100
Time limit: 2.0s
Memory limit: 256M

Author:
Problem types

Traverse all vertices of an undirected graph by BFS. Start at vertex 1; after a component finishes, restart at the smallest unvisited vertex. Smaller neighbors have priority.

Input

The first line contains n and m. The next m lines contain undirected edges.

  • 1 <= n <= 100

Output

Print one visited vertex per line.

Example

Input
7 5
1 2
1 3
2 4
5 6
6 7
Output
1
2
3
4
5
6
7

Comments

There are no comments at the moment.