Articulation points - Timestamps#10224

Articulation points - Timestamps

1 second
128 megabytes
Very easy

An undirected graph is given. Run a depth-first search from the given vertex . Print the timestamps d_v and up_v for each vertex in the increasing order of vertices.

Input

The first line contains the number of vertices (n \le 100) and edges of an undirected graph. Vertices are numbered from to . Each of the next lines contains two vertices and - an undirected edge of the graph. The last line contains vertex , from which the search begins.

Output

Run . Print the timestamps d_v and up_v for each vertex (v = 1, 2, \ldots, n). The timestamps for each vertex must be printed on a separate line.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Note

Use the adjacency matrix for storing the graph.

prb10224.gif