Untitled

                Never    
C++
       
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#endif
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long double ld;

#define double long double
#define mk make_pair
#define inb push_back
#define enb emplace_back
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define sqr(x) (x) * (x)
#define TIME 1.0 * clock() / CLOCKS_PER_SEC
#define y1 yyyyyy
//continue break pop_back return

int solve();
		   
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#define TASK ""
#ifndef _DEBUG
	//freopen(TASK".in", "r", stdin), freopen(TASK".out", "w", stdout);
#endif
	solve();
#ifdef _DEBUG
	fprintf(stderr, "\nTIME: %.3f\n", TIME);
#endif
}

int solve()
{
	int n;
	cin >> n;
	vector<vi> g(n, vi(n));
	if (n == 1)
		puts("0"), exit(0);
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			cin >> g[i][j];
		}
	}
	vector<vi> dp(n, vi(1 << n, -1));
	dp[0][1] = 0;
	for (int msk = 0; msk < (1 << n); ++msk)
	{
		for (int i = 0; i < n; ++i)
		{
			if ((msk >> i) & 1 && dp[i][msk] != -1)
			{
				for (int j = 0; j < n; ++j)
				{
					if ((msk >> j) & 1 == 0)
					{
						int new_value = dp[i][msk] + g[i][j];
						dp[j][msk | (1 << j)] = dp[j][msk | (1 << j)] == -1 ? new_value : min(new_value, dp[j][msk | (1 << j)]);
					}
				}
			}
		}
	}
	int ans = dp[1][(1 << n) - 1] + g[1][0];
	for (int i = 2; i < n; ++i)
	{
		ans = min(ans, dp[i][(1 << n) - 1] + g[i][0]);
	}
	printf("%d\n", ans);
	return 0;
}