from collections import defaultdict, deque, Counter import copy from itertools import combinations, permutations, product, accumulate, groupby from heapq import heapify, heappop, heappush import math import bisect from pprint import pprint from random import randint import sys # sys.setrecursionlimit(700000) input = lambda: sys.stdin.readline().rstrip('\n') inf = float('inf') mod1 = 10**9+7 mod2 = 998244353 def ceil_div(x, y): return -(-x//y) ################################################# N, X, Y = map(int, input().split()) dp = [-inf for _ in range((X+1)*(Y+1))] dp[0] = 0 for _ in range(N): a, b, c = map(int, input().split()) ndp = [-inf]*(X+1)*(Y+1) for i in range(X+1): for j in range(Y+1): ndp[i*(Y+1)+j] = max(ndp[i*(Y+1)+j], dp[i*(Y+1)+j]) if i+a <= X and j+b <= Y: ndp[(i+a)*(Y+1)+j+b] = max(ndp[(i+a)*(Y+1)+j+b], dp[i*(Y+1)+j]+c) dp = ndp print(max(dp))