You are developing a system for analyzing dependencies between the modules of the software project. Each module can depend on other modules, and you need to build a dependence graph, identify cyclic dependencies and determine the correct procedure for loading the modules.
rn
The system should calculate the level of each module (the maximum depth of the dependence chain to it) and perform topological sorting to determine the safe loading order.
Input format
the first line contains the number n-the number of modules.
The following n strings; They contain a description of dependencies in the format:
name_modula: dependence1 dependence2 ... Dependence
rn
Output format
cycle Detiateded Div> rn Otherwise:
rn rn - rn
line with the procedure for loading modules through a gap rn
- rn
n lines in format & nbsp; module Level
rn rn
Example
Input
4
Main: Utils Database
Utils: Config
Database: Config
config:
Output
config utils database main
config: 0
utils: 1
daatabase: 1
main: 2
Hint
There will be no clue here, decide for yourself!