N, X, Y = map(int, input().split()) xs = [] for _ in range(N): A, B, C = map(int, input().split()) xs.append((A, B, C)) dp = [[-1] * 301 for _ in range(301)] dp[0][0] = 0 ans = 0 for a, b, c in xs: for i in reversed(range(X+1)): for j in reversed(range(Y+1)): if dp[i][j] == -1: continue ni = i + a nj = j + b if ni <= X and nj <= Y: dp[ni][nj] = max(dp[ni][nj], dp[i][j] + c) ans = max(ans, dp[ni][nj]) print(ans)