import sys sys.setrecursionlimit(10**7) n=int(input()) c=[list(map(int,input().split())) for _ in range(n)] inf=float('inf') memo={} memo[0]=0 d={} for i in range(n): d[2**i+2**(i+n)]=i def func(red,pre): key=(red,pre) if red==0:memo[key]=0 if red in d: i=d[red] return c[pre][i] if key in memo:return memo[key] ret=inf for i in range(n): if i==pre:continue if (red>>i)&1: ret=min(ret,func(red^(1<>(n+i))&1: ret=min(ret,func(red^(1<<(n+i)),i)+c[pre][i]) memo[key]=ret return ret c.append([0]*n) ret=func(2**(2*n)-1,-1) print(ret)