#include #define REP(i,n) for(int i=0,i##_len=(n);i>N; vector> X(N,vector(N)); REP(i,N) REP(j,N) cin>>X[i][j]; vector A(N); REP(i, N) cin >> A[i]; int ans=INT_MAX; vector B(N,false); REP(bit,1<>j&1){ res+=A[j]; } bool flag=true; REP(i,N){ bool zihaku=true; REP(j,N) if(X[i][j]&&(~bit>>j&1)) zihaku=false; B[i]=zihaku; } REP(i,N) if(!B[i]&&~bit>>i&1){ rep(j,i+1,N) if(!B[j]&&~bit>>j&1){ if(X[i][j]&&X[j][i]) flag=false; } } if(flag) ans=min(ans,res); } cout<