#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int maxs=1<<18;
int n,m,opt[maxs][18];
int a[20][20];
int main()
{
freopen("salesman.in","r",stdin);
freopen("salesman.out","w",stdout);
scanf("%d",&n);
for (int i=1;i<=n;++i)
for (int j=1;j<=n;++j)
scanf("%d",&a[i][j]);
for (int i=3;i<1<<n;++i)
for (int j=1;j<=n;++j)
opt[i][j]=0x7fffffff/3;
for (int i=3;i<1<<n;++i)
for (int j=2;j<=n;++j)
if (i&(1<<j-1))
for (int k=1;k<=n;++k)
if (j!=k&&(i&(1<<k-1)))
opt[i][j]=min(opt[i][j],opt[i^(1<<j-1)][k]+a[k][j]);
int ans=0x7fffffff;
for (int i=1;i<=n;++i){
opt[(1<<n)-1][i]+=a[i][1];//不要写a[1][i]......
ans=min(ans,opt[(1<<n)-1][i]);
}
printf("%d",ans);
return 0;
}