import sys input = sys.stdin.readline N,X,Y=map(int,input().split()) A=[list(map(int,input().split())) for i in range(N)] DP=[[0]*(Y+1) for i in range(X+1)] for a,b,c in A: for i in range(X,-1,-1): for j in range(Y,-1,-1): if i+a<=X and j+b<=Y: DP[i+a][j+b]=max(DP[i+a][j+b],DP[i][j]+c) ANS=0 for i in range(X+1): for j in range(Y+1): ANS=max(ANS,DP[i][j]) print(ANS)