Directed graph - timestamps#11243

Directed graph - timestamps

1 segundo
128 megabytes
Muy fácil

The directed graph is given in the form of an adjacency list. Run a depth-first search on the graph. Print the timestamps d_v and f_v for each vertex in ascending order of the vertices.

Entrada

The first line contains the number of vertices (1 \le n \le 100). The next -th line contains the number of edges adjacent to the -th vertex and the vertex numbers.

Salida

Run a depth-first search on the graph. Print the timestamps d_v and f_v for each vertex (v = 1, 2, \ldots, n). Print the timestamps for each vertex on a separate line.

Ejemplos

Ejemplo 1

Loading
Loading