# import pypyjit;pypyjit.set_param("max_unroll_recursion=-1") # from bisect import * # from collections import * # from heapq import * # from itertools import * # from math import * # from datetime import * # from decimal import* # from string import ascii_lowercase,ascii_uppercase # import numpy as np import sys import os # sys.setrecursionlimit(10**6) INF = 10**18 MOD = 998244353 # MOD = 10**9 + 7 File = open("input.txt", "r") if os.path.exists("input.txt") else sys.stdin def input(): return File.readline()[:-1] # /////////////////////////////////////////////////////////////////////////// N, X, Y = map(int, input().split()) menu = [list(map(int, input().split())) for _ in range(N)] + [[0, 0, 0]] dp = [[[0, 0] for _ in range(700)] for _ in range(N + 1)] flag = [0] * 700 flag[0] = 1 for i in range(N + 1): for j in range(500): if flag[j]: if j + menu[i][0] <= X and dp[i - 1][j][0] + menu[i][1] <= Y: dp[i][j + menu[i][0]] = ( dp[i][j + menu[i][0]] if dp[i][j + menu[i][0]][1] > dp[i - 1][j][1] + menu[i][2] else [ dp[i - 1][j][0] + menu[i][1], dp[i - 1][j][1] + menu[i][2], ] ) flag[j + menu[i][0]] = 1 dp[i][j] = dp[i][j] if dp[i][j][1] > dp[i - 1][j][1] else dp[i - 1][j] ans = 0 for i, j in enumerate(dp[-1]): if i <= X and j[0] <= Y: if ans < j[1]: ans = j[1] print(ans)