Under construction

Still being built. Things may change

Emptying the Glasses

Time limit2sMemory limit32 MB

Summary
Given N glasses and pairwise pour costs, find the minimum effort to end with water in at most K glasses.
Level

Medium6 of 10

Topics
Dynamic programming, Graph, Bit manipulation, Shortest path
Solved
No attempts yet

Problem

Mislav has NN glasses of unlimited volume, and every glass holds some water. He wants to drink all of the water, but he does not want to drink from more than KK glasses. The only thing he can do is pour all of the water from one glass into another glass.

The glasses are not all the same distance away from him, so the choice of glasses matters. Pouring the water from glass ii into glass jj costs CijC_{ij} effort.

Find the smallest total effort needed to leave water in at most KK glasses.

Input

The first line contains the integers NN and KK (1≤K≤N≤201 \le K \le N \le 20).

Each of the next NN lines contains NN integers. The jj-th number on the ii-th line is CijC_{ij} (0≤Cij≤1000000 \le C_{ij} \le 100000). Cii=0C_{ii} = 0 holds for every ii.

Output

Print the minimum total effort on one line.

Hint

If at most KK glasses hold water from the start, no pouring is needed and the answer is 0.

Water may travel through several glasses. Mislav can pour glass ii into glass jj, then later pour glass jj into glass kk.

Examples3

  1. Example 1

    Input
    3 3
    0 1 1
    1 0 1
    1 1 0
    
    Expected output
    0
    
  2. Example 2

    Input
    3 2
    0 1 1
    1 0 1
    1 1 0
    
    Expected output
    1
    
  3. Example 3

    Input
    5 2
    0 5 4 3 2
    7 0 4 4 4
    3 3 0 1 2
    4 3 1 0 5
    4 5 5 5 0
    
    Expected output
    5