n,X,Y=map(int,input().split()) INF=10**20 q=[[-INF]*(Y+1) for i in range(X+1)] q[0][0]=0 for _ in range(n): a,b,c=map(int,input().split()) for i in reversed(range(X+1)): for j in reversed(range(Y+1)): if q[i][j]>-INF: if i+a<=X and j+b<=Y: q[i+a][j+b]=max(q[i+a][j+b],q[i][j]+c) print(max(max(q[i]) for i in range(X+1)))