N,X,Y = map(int,input().split()) dp = [] for i in range(X+1): dp.append([-1]*(Y+1)) dp[0][0] = 0 for _ in range(N): A,B,C = map(int,input().split()) for i in range(X,0,-1): for j in range(Y+1): if j-B >= 0 and i-A >= 0 and dp[i-A][j-B] != -1: dp[i][j] = max(dp[i][j],dp[i-A][j-B]+C) ans = 0 for i in range(X+1): for j in range(Y+1): ans = max(ans,dp[i][j]) print(ans)