Articulation points - Timestamps#10224

Articulation points - Timestamps

1 seconde
128 mégaoctets
Très facile

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.

Entrée

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.

Sortie

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.

Exemples

Exemple 1

Loading
Loading

Exemple 2

Loading
Loading

Note

Use the adjacency matrix for storing the graph.

prb10224.gif