Fixed dfs and toposort output