N=int(input()) ABC=[] for i in range(N): a,b,c=map(int,input().split()) ABC.append((a,b,c)) def idx(bit,i,x,y): return ((bit*N+i)*3+x)*3+y trans=[[] for ij in range(N*N)] for i in range(N): for j in range(N): if i==j: continue for x0 in range(3): for y0 in range(x0+1,3): if x0==y0: continue for x1 in range(3): for y1 in range(x1+1,3): if x1==y1: continue if ABC[i][x0]>=ABC[j][x1] and ABC[i][y0]>=ABC[j][y1] or ABC[i][x0]>=ABC[j][y1] and ABC[i][y0]>=ABC[j][x1]: trans[i*N+j].append((x0,y0,x1,y1,ABC[j][3-x1-y1])) inf=1<<30 dp=[-inf]*((9*N)<