/*
floyd预处理+状压dp
*/
#include<cstdio>
#include<cstring>
#define maxn 40010
using namespace std;
int n,g[16][16],f[maxn][16],ans;
int min(int x,int y){return x<y?x:y;}
int main()
{
scanf("%d",&n);
memset(f,127/3,sizeof(f));
for(int i=0;i<=n;i++)
for(int j=0;j<=n;j++)
scanf("%d",&g[i][j]);
for(int k=0;k<=n;k++)
for(int i=0;i<=n;i++)
for(int j=0;j<=n;j++)
g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
/*__________________________________________________________________________*/
ans=f[0][0];f[0][0]=0;
for(int i=1;i<(1<<n);i++)
for(int j=1;j<=n;j++)if(i&(1<<j-1))
for(int k=0;k<=n;k++)
f[i][j]=min(f[i][j],f[i-(1<<j-1)][k]+g[k][j]);
for(int i=1;i<=n;i++)
ans=min(ans,f[(1<<n)-1][i]+g[i][0]);
printf("%d\n",ans);
return 0;
}