n, X, Y = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(n)]

INF = float('-inf')
dp = [[INF] * (Y + 1) for _ in range(X + 1)]
dp[0][0] = 0  # Initial state: no items selected

for a, b, c in items:
    # Iterate backwards to prevent reusing the same item
    for x in range(X, a - 1, -1):
        for y in range(Y, b - 1, -1):
            if dp[x - a][y - b] != INF and dp[x - a][y - b] + c > dp[x][y]:
                dp[x][y] = dp[x - a][y - b] + c

# Find the maximum value across all dp states
max_val = max(max(row) for row in dp)
print(max(max_val, 0))