Fix reach for topological sort