#include #define rep(i,n) for(int i=0; i<(int)(n); i++) using namespace std; using LL = long long; const int INF = 1e9; int c[12][12]; int main(){ int N, M; cin >> N; rep(i,N){ rep(j,N) cin >> c[i][j]; } M=1; int ans=INF; vector p; rep(i,N){ //if(i==0) rep(j,M) p.emplace_back(i); rep(j,M+1) p.emplace_back(i); } do{ bool test=true; rep(i,N*(M+1)-2){ if(p[i]==p[i+1]){ test=false; break; } } if(!test) continue; int res=0, now=p[0]; rep(i,N*(M+1)-1){ int next=p[i+1]; res+=c[now][next]; now=next; } ans=min(ans,res); }while(next_permutation(p.begin(),p.end())); cout << ans << endl; return 0; }