#include<iostream>
#include<algorithm>
using namespace std;
int arr[12][12] = { 0, };
int dp[12][1 << 12] = { 0, };
int N;
int TSP(int start, unsigned int mid, int dep) {
if (dp[start][mid]) {
return dp[start][mid];
}
if (dep == 1) {
dp[start][mid] = arr[start][0];
return arr[start][0];
}
int ret;
dp[start][mid] = 11000000;
for (int i = 0; i<N; i++) {
if ((1 << i) & mid) {
int tmp = TSP(i, mid - (1 << i), dep - 1);
if (tmp != 0 &&arr[start][i]) {
dp[start][mid] = min(dp[start][mid], arr[start][i] + tmp);
}
//printf("%d %d %d %u %d %d\n",dep, start, i, mid, arr[start][i] +tmp, dp[start][mid]);
}
}
if (dp[start][mid] == 11000000) {
dp[start][mid] = 0;
return 0;
}
return dp[start][mid];
}
int main() {
cin >> N;
unsigned int mid = 0;
for (int i = 0; i<N; i++) {
mid = (mid << 1) + 1;
for (int j = 0; j<N; j++) {
cin >> arr[i][j];
}
}
cout << TSP(0, mid - 1, N) << endl;
}