N, X, Y = map(int, input().split()) dp = [[0]*(Y+1) for _ in range(X+1)] for _ in range(N): a, b, c = map(int, input().split()) for x in range(X, a-1, -1): for y in range(Y, b-1, -1): dp[x][y] = max(dp[x][y], dp[x-a][y-b] + c) print(dp[X][Y])