UVA125 - Numbering Paths

graph theory, DFS, cycles, strongly connected components (or
Floyd-Warshall/transitive closure).