#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const bool debug = true;
#define ff first
#define ss second
#define yes cout << "Yes\n"
#define no cout << "No\n"
#define YN(x) if(x)yes; else no;
#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()
#define blt __builtin_popcount
const int mod = 1e9 + 7;
#ifndef ONLINE_JUDGE
#define dbg(x) cerr << #x <<" "; print(x); cerr << endl;
#else
#define dbg(x)
#endif
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif
void print(long long t) { cerr << t; }
void print(int t) { cerr << t; }
void print(string t) { cerr << t; }
void print(char t) { cerr << t; }
void print(double t) { cerr << t; }
void print(long double t) { cerr << t; }
void print(unsigned long long t) { cerr << t; }
template <class T, class V> void print(pair <T, V> p);
template <class T> void print(vector <T> v);
template <class T> void print(set <T> v);
template <class T, class V> void print(map <T, V> v);
template <class T> void print(multiset <T> v);
template <class T, class V> void print(T v[], V n) { cerr << "["; for (int i = 0; i < n; i++) { cerr << v[i] << " "; } cerr << "]"; }
template <class T, class V> void print(pair <T, V> p) { cerr << "{"; print(p.first); cerr << ","; print(p.second); cerr << "}"; }
template <class T> void print(vector <T> v) { cerr << "[ "; for (T i : v) { print(i); cerr << " "; } cerr << "]"; }
template <class T> void print(set <T> v) { cerr << "[ "; for (T i : v) { print(i); cerr << " "; } cerr << "]"; }
template <class T> void print(multiset <T> v) { cerr << "[ "; for (T i : v) { print(i); cerr << " "; } cerr << "]"; }
template <class T, class V> void print(map <T, V> v) { cerr << "[ "; for (auto i : v) { print(i); cerr << " "; } cerr << "]"; }
template <class T> void print(queue <T> q) { cerr << "[ "; while (!q.empty()) { print(q.front()); cerr << " "; q.pop(); } cerr << "]"; }
template <class T> void print(priority_queue <T> q) { cerr << "[ "; while (!q.empty()) { print(q.top()); cerr << " "; q.pop(); } cerr << "]"; }
template <class T> void print(int n__, T arr[]) { cerr << "[ "; for (int i = 0; i <= n__; i++) { print(arr[i]); cerr << " "; } cerr << "]"; }
ll gcdll(ll a, ll b) { return b == 0 ? a : gcdll(b, a % b); }
long long mult(long long a, long long b)
{
return (a * b) % mod;
}
long long binpow(long long a, long long b) {
long long res = 1;
a %= mod;
while (b > 0) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res;
}
long long m_inverse(long long n) {
return binpow(n, mod - 2);
}
long long divide(long long a, long long b) {
return (a % mod * m_inverse(b)) % mod;
}
long long sub(long long a, long long b)
{
if (a - b >= 0)return a - b;
else return a - b + mod;
}
long long add(long long a, long long b)
{
if (a + b >= mod)return a + b - mod;
else return a + b;
}
const int LOG = 21;
const int N = 20 + 5;
const int inf = 1e9;
int a[N][N];
int dp[(1 << LOG)];
void solve()
{
int n, k;
cin >> n >> k;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
cin >> a[i][j];
vector<int>g;
for (int mask = 0; mask < (1 << n); mask++)
{
int b = blt(mask);
if (b <= k)
dp[mask] = 0;
else
{
dp[mask] = inf;
for (int i = 0; i < n; i++)
if (mask & (1 << i))
g.push_back(i);
int m = g.size();
for (int i = 0; i < m; i++)
for (int j = i + 1; j < m; j++)
dp[mask] = min({ dp[mask], dp[mask ^ (1 << g[i])] + a[g[i]][g[j]],
dp[mask ^ (1 << g[j])] + a[g[j]][g[i]] });
g.clear();
}
}
cout << dp[(1 << n) - 1];
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t = 1;
//cin >> t;
while (t--)
{
solve();
}
return 0;
}