#include <stdio.h>
int c[25][25];
int dp[(1<<20)+5];
int main(){
int N, K;
scanf("%d%d", &N, &K);
for(int i=0; i<N; i++) for(int j=0; j<N; j++) scanf("%d", &c[i][j]);
for(int i=1; i<(1<<N); i++) dp[i] = 2e9;
int res = 2e9;
for(int mask=0; mask<(1<<N); mask++){
int bcnt = __builtin_popcount(mask);
if(N-bcnt <= K && dp[mask] < res) res = dp[mask];
for(int i=0; i<N; i++){
if(mask&(1<<i)) continue;
int newbit = mask|(1<<i);
int cost = 2e5;
for(int j=0; j<N; j++){
if((mask&(1<<j)) || j == i) continue;
if(c[i][j] < cost) cost = c[i][j];
}
if(dp[mask]+cost < dp[newbit]) dp[newbit] = dp[mask]+cost;
}
}
printf("%d", res);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgY1syNV1bMjVdOwppbnQgZHBbKDE8PDIwKSs1XTsKCmludCBtYWluKCl7CiAgICBpbnQgTiwgSzsKICAgIHNjYW5mKCIlZCVkIiwgJk4sICZLKTsKICAgIGZvcihpbnQgaT0wOyBpPE47IGkrKykgZm9yKGludCBqPTA7IGo8TjsgaisrKSBzY2FuZigiJWQiLCAmY1tpXVtqXSk7CiAgICBmb3IoaW50IGk9MTsgaTwoMTw8Tik7IGkrKykgZHBbaV0gPSAyZTk7CiAgICBpbnQgcmVzID0gMmU5OwogICAgZm9yKGludCBtYXNrPTA7IG1hc2s8KDE8PE4pOyBtYXNrKyspewogICAgICAgIGludCBiY250ID0gX19idWlsdGluX3BvcGNvdW50KG1hc2spOwogICAgICAgIGlmKE4tYmNudCA8PSBLICYmIGRwW21hc2tdIDwgcmVzKSByZXMgPSBkcFttYXNrXTsKICAgICAgICBmb3IoaW50IGk9MDsgaTxOOyBpKyspewogICAgICAgICAgICBpZihtYXNrJigxPDxpKSkgY29udGludWU7CiAgICAgICAgICAgIGludCBuZXdiaXQgPSBtYXNrfCgxPDxpKTsKICAgICAgICAgICAgaW50IGNvc3QgPSAyZTU7CiAgICAgICAgICAgIGZvcihpbnQgaj0wOyBqPE47IGorKyl7CiAgICAgICAgICAgICAgICBpZigobWFzayYoMTw8aikpIHx8IGogPT0gaSkgY29udGludWU7CiAgICAgICAgICAgICAgICBpZihjW2ldW2pdIDwgY29zdCkgY29zdCA9IGNbaV1bal07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYoZHBbbWFza10rY29zdCA8IGRwW25ld2JpdF0pIGRwW25ld2JpdF0gPSBkcFttYXNrXStjb3N0OwogICAgICAgIH0KICAgIH0KICAgIHByaW50ZigiJWQiLCByZXMpOwogICAgcmV0dXJuIDA7Cn0=