Depth First Search
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
The undirected graph is given. Start a depth-first search from the given vertex and print the vertex numbers in the order of their first visit.
Input
The first line contains the number of vertices and edges of the graph. Each of the following lines contains two vertices and — an undirected edge of the graph. The last line contains the vertex .
Output
Start a depth-first search from vertex and print the vertex numbers in the order of their first visit.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 4K
Acceptance rate 62%