#include<bits/stdc++.h>
using namespace std;
int n,city[16][16],dp[16][(1<<16)];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
memset(city,63,sizeof(city));
cin>>n;
for(int i=0;i<=n;i++){
for(int j=0;j<=n;j++){
cin>>city[i][j];
}
}
for(int k=0;k<=n;k++){
for(int i=0;i<=n;i++){
for(int j=0;j<=n;j++){
city[i][j]=min(city[i][j],city[i][k]+city[k][j]);
}
}
}
memset(dp,63,sizeof(dp));
dp[0][0]=0;
for(int k=0;k<=(1<<(n+1))-1;k++){
for(int i=0;i<=n;i++){
if((k|(1<<i))==k){
for(int j=0;j<=n;j++){
dp[i][k]=min(dp[i][k],min(dp[j][k-(1<<i)],dp[j][k])+city[i][j]);
}
}
}
}
cout<<dp[0][(1<<(n+1))-1];
return 0;
}