# 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] * (Y + 1) for _ in range(X + 1)] for _ in range(N + 1)] flag = [[0] * (Y + 1) for _ in range(X + 1)] flag[0][0] = 1 for i in range(N): for j in range(X + 1): for k in range(Y + 1): if flag[j][k] == 1: if j + menu[i][0] <= X and k + menu[i][1] <= Y: dp[i][j + menu[i][0]][k + menu[i][1]] = max( dp[i][j + menu[i][0]][k + menu[i][1]], dp[i - 1][j][k] + menu[i][2], ) flag[j + menu[i][0]][k + menu[i][1]] = 1 dp[i][j][k] = max((dp[i][j][k], dp[i - 1][j][k])) ans = 0 for i in dp[N - 1]: ans = max(ans, max(i)) print(ans)