#include<bits/stdc++.h>
using namespace std;
const int maxn = 17;
#define inf 0x3f3f3f3f
inline int read(){
int f=1,x=0;
char ch=getchar();
while(!isdigit(ch)){
if(ch=='-') f=-1;
ch=getchar();
}
while(isdigit(ch)){
x=(x<<3)+(x<<1)+ch-'0';
ch=getchar();
}
return x*f;
}
#define read(x) x=read()
int n,full=(1<<16)-1,dis[maxn][maxn],f[1<<16][maxn];
int main(){
read(n);
for(int i=0;i<=n;i++)
for(int j=0;j<=n;j++) read(dis[i][j]);
for(int k=0;k<=n;k++)
for(int i=0;i<=n;i++)
for(int j=0;j<=n;j++) dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
memset(f,inf,sizeof(f));
f[0][0]=0;
for(int s=0;s<(1<<n+1);s++)
for(int i=0;i<=n;i++){
if((s&(1<<i))==0) continue;
for(int j=0;j<=n;j++){
//if((s&(1<<j))==0) continue;
f[s][i]=min(f[s][i],min(f[s][j],f[s-(1<<i)][j])+dis[j][i]);
}
}
printf("%d",f[(1<<n+1)-1][0]);
return 0;
}