Graph Without Long Directed Paths

CodeForces - 1144F