you give integer n indicate n course label 1 n you give array relation relationsi prevCoursei nextCoursei represent prerequisite relationship course prevcoursei course nextCoursei course prevCoursei take course nextCoursei also give integer kIn semester k course long take prerequisite previous semester course takingreturn minimum number semester need course the testcase generate possible course Example 1input n 4 relation 213114 k 2output 3explanation the figure represent give graphin semester course 2 3in second semester course 1in semester course 4example 2input n 5 relation 21314115 k 2output 4explanation the figure represent give graphin semester course 2 3 semesterin second semester course 4in semester course 1in fourth semester course 5 Constraints1 n 151 k n0 relationslength n n1 2relationsilength 21 prevcoursei nextCoursei nprevCoursei nextCourseiAll pair prevcoursei nextCoursei uniquethe give graph direct acyclic graph