n,x,y = map(int,input().split()) m = [list(map(int,input().split())) for i in range(n)] INF = 10**15 dp = [[[-INF]*(y+1) for i in range(x+1)] for i in range(n+1)] dp[0][0][0] = 0 for i in range(1, n+1): a,b,c, = m[i-1] for j in range(y+1): for k in range(x+1): dp[i][j][k] = dp[i-1][j][k] if j-a >= 0 and k-b >= 0: dp[i][j][k] = max(dp[i][j][k] ,dp[i-1][j-a][k-b] + c) ans = -INF for j in range(x+1): for k in range(y+1): ans = max(ans, dp[-1][j][k]) print(ans)