#include using namespace std; using ll = long long; #define FOR(i, a, b) for (int i = (a); i < int(b); ++i) #define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i) #define rep(i, n) FOR(i, 0, n) #define rep1(i, n) FOR(i, 1, int(n) + 1) #define rrep(i, n) RFOR(i, 0, n) #define rrep1(i, n) RFOR(i, 1, int(n) + 1) #define all(c) begin(c), end(c) const int MOD = 1000000007; template void __dump__(std::ostream &os, const T &first) { os << first; } template void __dump__(std::ostream &os, const First &first, const Rest &... rest) { os << first << ", "; __dump__(os, rest...); } #define dump(...) \ do { \ std::ostringstream os; \ os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \ __dump__(os, __VA_ARGS__); \ std::cerr << os.str() << std::endl; \ } while (0) int dp[1<<24]; int f[24][24]; int n; int main() { while (cin >> n) { memset(dp, -1, sizeof dp); rep(i, n) rep(j, n) cin >> f[i][j]; dp[0] = 0; rep(S, 1<> i & 1) ++i; rep(j, n) { if (i == j) continue; if (S >> j & 1) continue; int cand = f[i][j] + dp[S]; int nS = S|1<