import heapq N, X, Y = map(int, input().split()) dp = [[float('-inf')] * (Y + 1) for _ in range(X + 1)] dp[0][0] = 0 for _ in range(N): A, B, C = map(int, input().split()) for i in range(X - A, -1, -1): for j in range(Y - B, -1, -1): dp[i + A][j + B] = max(dp[i + A][j + B], dp[i][j] + C) max_value = float('-inf') for i in range(X + 1): for j in range(Y + 1): if dp[i][j] != float('-inf'): max_value = max(max_value, dp[i][j]) print(max_value)