import heapq N, X, Y = map(int, input().split()) dp = [[-1] * (Y + 1) for _ in range(X + 1)] dp[0][0] = 0 for _ in range(N): A, B, C = map(int, input().split()) heap = [] for i in range(X - A + 1): for j in range(Y - B + 1): if dp[i][j] != -1: heapq.heappush(heap, (-dp[i][j], i, j)) while heap: val, i, j = heapq.heappop(heap) dp[i + A][j + B] = max(dp[i + A][j + B], -val + C) ans = 0 for i in range(X + 1): for j in range(Y + 1): if dp[i][j] != -1: ans = max(ans, dp[i][j]) print(ans)