topo sort works