Now there are n independent projects, each project is composed by several steps, each step is labeled, there are k workers are going to work on these projects. Assume that each person can do only one step, and each step can only be done by a specific worker(it will be declared in input file). Each project has a order for its steps, for example, workers can operate the second step only if the first step has been done. when one person finished one step, then he can be assigned to another step immediately.

Task:Input the number of projects, and the number of steps of each project, and the worker corresponds to each step, and how much time it will take to finish the step. Try to find an algorithm to calculate the optimized time to finish all projects. Example inputs:

2 3(2 projects, 3 workers)

3 1 2 2 3 3 5(for project 1, there are 3 steps, the first will be done by worker 1 takes 2 hours, the second will be done by worker 2 by 3 hours, the third will be done by worker 3 by 5 hours)

2 2 3 3 2(for project 2, there are 2 steps, the first will be done by worker 2 by 3 hours, the second will be done by worker 3 by 2 hours)

Output 11 ( the minimized hours to finish the whole project)