#include<bits/stdc++.h>
inline const void read(int &a)
{
a=0;char c=getchar();
while(c<'0'||c>'9')c=getchar();
while(c>='0'&&c<='9')
{
a=(a<<1)+(a<<3)+c-'0';
c=getchar();
}
}
int n,len[16][16],dis[16][1<<16];
bool in_que[16][1<<16];
struct queue
{
int que[100000],cond[100000],start,end;
inline const void init(){start=0;end=-1;}
inline const bool empty(){if(start>end)return true;return false;}
inline const void push(int a,int b){que[++end]=a;cond[end]=b;}
inline const void pop(){in_que[que[start]][cond[start]]=false;start++;}
inline const int front_que(){return que[start];}
inline const int front_cond(){return cond[start];}
}path;
void spfa()
{
while(!path.empty())
{
int k=path.front_que(),p=path.front_cond();
if(dis[0][p]>dis[k][p]+len[k][0])
{
dis[0][p]=dis[k][p]+len[k][0];
if(!in_que[0][p])
{
path.push(0,p);
in_que[0][p]=true;
}
}
for(int i=1;i<=n;i++)
{
if(dis[i][p|1<<i-1]>dis[k][p]+len[k][i])
{
dis[i][p|(1<<i-1)]=dis[k][p]+len[k][i];
if(!in_que[i][p|(1<<i-1)])
{
path.push(i,p|(1<<i-1));
in_que[i][p|(1<<i-1)]=true;
}
}
}
path.pop();
}
}
int main()
{
path.init();
memset(in_que,false,sizeof(in_que));
read(n);
for(int i=0;i<=n;i++)
for(int j=0;j<=n;j++)read(len[i][j]);
memset(dis,0x7f,sizeof(dis));
dis[0][0]=0;path.push(0,0);in_que[0][0]=true;
spfa();
std::cout<<dis[0][(1<<n)-1];
return 0;
}