#include <bits/stdc++.h>
using namespace std;
int n,k;
int a[20][20];
int dp[1500000];
int solve(int mask)
{
int temp,cnt=0,temp2;
if(__builtin_popcount(mask)<=k) return 0;
if(dp[mask]!=-1)
{
return dp[mask];
}
int mn=10e8;
for(temp=0;temp<n;temp++)
{
for(temp2=temp+1;temp2<n;temp2++)
{
if((mask & (1<<temp))&& (mask & (1<<temp2)))
{
mn=min(mn,a[temp][temp2] + solve(mask ^ (1 << temp)));
mn=min(mn,a[temp2][temp] + solve(mask ^ (1<< temp2)));
}
}
}
dp[mask]=mn;
return mn;
}
int main()
{
memset(dp,-1,sizeof(dp));
scanf("%d %d",&n,&k);
int temp,temp2;
for(temp=0;temp<n;temp++)
{
for(temp2=0;temp2<n;temp2++)
{
scanf("%d",&a[temp][temp2]);
}
}
printf("%d\n",solve((1<<n)-1));
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbixrOwppbnQgYVsyMF1bMjBdOwppbnQgZHBbMTUwMDAwMF07CgppbnQgc29sdmUoaW50IG1hc2spCnsKCWludCB0ZW1wLGNudD0wLHRlbXAyOwoJaWYoX19idWlsdGluX3BvcGNvdW50KG1hc2spPD1rKQlyZXR1cm4gMDsKCWlmKGRwW21hc2tdIT0tMSkKCXsKCQlyZXR1cm4gZHBbbWFza107Cgl9CglpbnQgbW49MTBlODsKCWZvcih0ZW1wPTA7dGVtcDxuO3RlbXArKykKCXsKCQlmb3IodGVtcDI9dGVtcCsxO3RlbXAyPG47dGVtcDIrKykKCQl7CgkJCWlmKChtYXNrICYgKDE8PHRlbXApKSYmIChtYXNrICYgKDE8PHRlbXAyKSkpIAoJCQl7CgkJCQltbj1taW4obW4sYVt0ZW1wXVt0ZW1wMl0gKyBzb2x2ZShtYXNrIF4gKDEgPDwgdGVtcCkpKTsKCQkJCW1uPW1pbihtbixhW3RlbXAyXVt0ZW1wXSArIHNvbHZlKG1hc2sgXiAoMTw8IHRlbXA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