Depth First Search - Timestamps#489

Depth First Search - Timestamps

1 second
128 megabytes
Easy (≈1000)

Undirected graph is given. Run depth first search from the given vertex . Print the timestamps and for each vertex in the increasing order of vertices.

Input

The first line contains number of vertices n~(n \le 100) and edges of undirected graph. Each of the next lines contains two vertices and — an undirected edge of the graph. The last line contains vertex .

Output

Run . Print the timestamps and for each vertex v~(v = 1, 2, ..., n). The timestamps for each vertex must be printed in a separate line.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading