import sys input = sys.stdin.readline N, M = map(int, input().split()) dp = [0] * (M + 1) for _ in range(N): a, b, c = map(int, input().split()) ndp = [-(10**18)] * (M + 1) for i in range(M - a + 1): ndp[i + a] = dp[i] + b * c for i in range(M - (a - b) + 1): ndp[i + a - b] = max(ndp[i + a - b], ndp[i] + b * c) for i in range(M + 1): dp[i] = max(dp[i], ndp[i]) print(*dp, sep="\n")