# coding: utf-8 # Your code here! import sys readline = sys.stdin.readline read = sys.stdin.read #n,m,s = [int(i) for i in readline().split()] n = int(input()) abc = [tuple(sorted(int(i) for i in readline().split())) for _ in range(n)] from bisect import * def solve(lst,n): lst.sort() dp = [0]*(n+1) for i,(w,h,c) in enumerate(lst): for j in range(i): if h >= lst[j][1]: dp[i] = max(dp[i], dp[j]+c) #print(lst,dp) return max(dp) #print(dp) N = 2**n ans = 0 for mask in range(N): res = [(0,0,0)] for i,(a,b,c) in enumerate(abc): if mask>>i&1: res.append((a,c,b)) else: res.append((a,b,c)) """ v = mask%3 mask //= 3 if v==0: res.append((a,c,b)) elif v==1: res.append((a,b,c)) else: res.append((b,c,a)) """ ans = max(ans,solve(res,n)) print(ans)