Catering

No attempts yetTime limit4sMemory limit256 MB

Problem

Paul runs a catering company and the business is busy. The company has kk catering teams, and each team is in charge of one set of catering equipment. Every week the company accepts nn catering requests for different events. For each request the company sends one team with its equipment to the event location. The team delivers the food, sets up the equipment, and shows the host how to use the equipment and how to serve the food. After the event the host returns the equipment to the company.

In some weeks the number of teams is smaller than the number of requests, so one team has to work more than one event. In that case the company cannot wait for the host to return the equipment, so the team stays on site and moves the equipment straight to the next location. The company knows the exact cost of moving one set of equipment from any location to any other location. Paul wants a plan that serves all nn requests with the smallest total moving cost, counting the first move out of the company. Using fewer than kk teams is allowed.

The requests are sorted in ascending order of event time, and for any two requests with i<ji < j there is enough time to move the equipment used for the iith request to the location of the jjth request.

Input

The first line contains the number of requests nn (1n1001 \le n \le 100) and the number of catering teams kk (1k1001 \le k \le 100). Each of the next nn lines describes one location: line ii contains ni+1n - i + 1 integers between 0 and 1000000 inclusive, and the jjth number on line ii is the cost of moving one set of equipment from location ii to location i+ji + j. The company is at location 1, and the nn requests are at locations 2 to n+1n + 1, one request per location.

Output

Print the minimum total moving cost that serves all requests. This amount does not include the cost of moving equipment back to the catering company.

Two different teams must not go to the same location. The starting location is the only location that more than one team can be at.