def main(): from sys import stdin, setrecursionlimit # setrecursionlimit(1000000) input = stdin.readline def iinput(): return int(input()) def sinput(): return input().rstrip() def i0input(): return int(input()) - 1 def linput(): return list(input().split()) def liinput(): return list(map(int, input().split())) def miinput(): return map(int, input().split()) def li0input(): return list(map(lambda x: int(x) - 1, input().split())) def mi0input(): return map(lambda x: int(x) - 1, input().split()) INF = 1000000000000000000 MOD = 1000000007 N, X, Y = miinput() dp = [0] * ((N + 1) * (X + 1) * (Y + 1)) def index(i, x, y): return i * (X + 1) * (Y + 1) + x * (Y + 1) + y for i in range(N): a, b, c = miinput() for x in range(X+1): for y in range(Y+1): dp[index(i+1, x, y)] = max(dp[index(i+1, x, y)], dp[index(i, x, y)]) if x + a <= X and y + b <= Y: dp[index(i+1, x+a, y+b)] = max(dp[index(i+1, x+a, y+b)], dp[index(i, x, y)] + c) print(dp[index(N, X, Y)]) main()