#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int g[20][20],dp[20][(1<<16)],n;
int main()
{
cin>>n;
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]);
memset(dp,127/3,sizeof(dp));
dp[0][0]=0;
int len=(1<<(n+1));
for (int k=0;k<len;k++)
for (int i=0;i<=n;i++)
{
if((k|(1<<i))!=k) continue;
for(int j=0;j<=n;j++)
dp[i][k]=min(dp[i][k],min(dp[j][k-(1<<i)],dp[j][k])+g[j][i]);
}
cout<<dp[0][len-1];
return 0;
}