INF = float('inf') N, X, Y = map(int, input().split()) dp = [[-INF] * (Y + 1) for _ in range(X + 1)] dp[0][0] = 0 for i in range(N): a, b, c = map(int, input().split()) for x in range(X, -1, -1): for y in range(Y, -1, -1): if x + a <= X and y + b <= Y: if dp[x + a][y + b] < dp[x][y] + c: dp[x + a][y + b] = dp[x][y] + c ans = -INF for x in range(X + 1): for y in range(Y + 1): ans = max(ans, dp[x][y]) print(ans)