Dependency cycles make modules impossible to change independently. Find one.
Input: lines from to until the end of input (module from depends on to). Modules are words.
Search for a cycle with a depth-first search: visit modules in order of first appearance in the input, and each module's dependencies in input order. When the search reaches a module that is already on the current path, a cycle is found: print it starting and ending at that module, e.g. Cycle: board -> post -> board, and stop.
If there is no cycle print No cycles followed by a topological order — the modules in an order where every module comes after all the modules it depends on — produced by the same DFS (a module is added when all its dependencies are finished), as Build order: a, b, c.
Input:
web board
board post
post repo
repo board
Output:
Cycle: board -> post -> repo -> board