#include<iostream>
#include<cstdio>
#include<cstring>
#define maxint 2147483647
using namespace std;
typedef long long llg;
int n,dp[500001][17];
int d[17][17];
int getint(){
int w=0,q=0;
char c=getchar();
while((c>'9'||c<'0')&&c!='-') c=getchar();
if(c=='-') q=1,c=getchar();
while(c>='0'&&c<='9') w=w*10+c-'0',c=getchar();
return q?-w:w;
}
int main(){
n=getint();n++;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
d[i][j]=getint();
for(int k=1;k<=n;k++)
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
if(i!=j && i!=k && j!=k)
if(d[i][k]+d[k][j]<d[i][j])
d[i][j]=d[i][k]+d[k][j];
memset(dp,0x7f,sizeof(dp));
dp[0][1]=0;
int i,j,l;
for(i=1;i<(1<<n);i++)
for(j=1;j<=n;j++)
for(l=1;l<=n;l++) if(j!=l && (i&(1<<(l-1))) && dp[i-(1<<(l-1))][l]+d[l][j]>=0)
dp[i][j]=min(dp[i][j],dp[i-(1<<(l-1))][l]+d[l][j]);
printf("%d",dp[(1<<n)-1][1]);
return 0;
}