N, M = map(int, input().split()) can = [list(map(int, input().split())) for _ in range(N)] INF = 10**18 dp = [[-INF]*(M+1) for _ in range(N+1)] dp[0][0] = 0 for i in range(N): A, B, C = can[i] first = A second = A-B for j in range(M+1): if dp[i+1][j] != -INF and j+second <= M: dp[i+1][j+second] = max(dp[i+1][j+second], dp[i+1][j]+C*B) if dp[i][j] != -INF: dp[i+1][j] = max(dp[i+1][j], dp[i][j]) if j+first <= M: dp[i+1][j+first] = max(dp[i+1][j+first], dp[i][j]+C*B) for i in range(1, M+1): dp[-1][i] = max(dp[-1][i], dp[-1][i-1]) print(*dp[-1][1:], sep="\n")