Example 1

Example 2

1 <= n <= 5 * 1040 <= relations.length <= min(n * (n - 1) / 2, 5 * 104)relations[j].length == 21 <= prevCoursej, nextCoursej <= nprevCoursej != nextCoursejAll the pairs [prevCoursej, nextCoursej] are unique.time.length == n1 <= time[i] <= 104The given graph is a directed acyclic graph.Example 1

Example 2

1 <= n <= 5 * 1040 <= relations.length <= min(n * (n - 1) / 2, 5 * 104)relations[j].length == 21 <= prevCoursej, nextCoursej <= nprevCoursej != nextCoursejAll the pairs [prevCoursej, nextCoursej] are unique.time.length == n1 <= time[i] <= 104The given graph is a directed acyclic graph.