Problem:
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Problem H:
Sightseeing Tour

KM city has $N$ sightseeing areas. Currently every pair of area is connected by a bidirectional road.

However for some reason, Mr. KM, the mayor of this city, decided to make all of these roads one-way . It costs $C_{i, j}$ dollars to renovate the road between area $i$ and area $j$ to a one-way road from area $i$ to area $j$. Of course, Mr. KM is economic and wants to minimize the total cost of the renovation.

On the other hand, because tourism is the most important industry for KM city, there must exists a tour that goes through all the sightseeing areas, visiting each area exactly once. The first and last area of the path need not to be the same. Can you calculate the minimum total cost required for the renovation, given this situation?

Input

The first line contains the number of sightseeing area $N$ ($1 \leq N \leq 100$). Next $N$ lines describe the integer matrix $C$, where the $j$-th element of the $i$-th row of the input describes $C_{i,j}$ ($0 \leq C_{i,j} \leq 1,000,000$). For each $i$, you can assume $C_{i,i}$ is always zero.

Output

Output the minimum cost in a line.

Sample Input 1

3
0 2 7
2 0 4
5 8 0

Sample Output 1

11

Solution in Python (judge verdict: Wrong Answer)

INF = float("inf")
N = int(raw_input())
cost = [map(int,raw_input().split(" ")) for _ in range(N)]
for i in range(N):
	cost[i][i] = INF
dp = [[[INF, []] for _ in range(N)] for _ in range(N-1)]
area = set(range(1,N))
dp[0] = [[v,area - set([idx])]  for idx, v in enumerate(cost[0])]

for i in range(N-1):
	for j in range(1,N):
		for next in dp[i][j][1]:
			tmpv = dp[i][j][0] + cost[j][next]
			if tmpv < dp[i+1][next][0]:
				dp[i+1][next] = [tmpv, dp[i][j][1] - set([next])]

for i in range(1,N):
	dp[N-2][i][0] += cost[i][0]
print min(dp[N-2])[0]