#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int map[20][20];
int dp[1<<16][20];
int n;
int main()
{
cin>>n;
memset(dp,127,sizeof(dp));
for(int i=0;i<=n;i++)
{
for(int j=0;j<=n;j++)
{
cin>>map[i][j];
}
}
for(int i=0;i<=n;i++)
{
for(int j=0;j<=n;j++)
{
for(int k=0;k<=n;k++)
{
if(i!=j&&map[i][k]+map[k][j]<map[i][j])
{
map[i][j]=map[i][k]+map[k][j];
}
}
}
}
int maxx=(1<<(n+1))-1;
for (int i=0;i<=n;i++) dp[0][i]=map[0][i];
for (int s=1;s<=maxx;s++)
for (int j=0;j<=n;j++)
if (!((1<<j)&s)){
for (int i=0;i<=n;i++){
if (s&(1<<i)){
dp[s][j]=min(dp[s][j],dp[s^(1<<i)][i]+map[i][j]);
}
}
}
cout<<dp[maxx-1][0];
return 0;
}