N,M = map(int,input().split()) dp = [[0 for _ in range(M+1)] for _ in range(N+1)] A = [0]+[list(map(int,input().split())) for _ in range(N)] for i in range(1,N+1): for j in range(1,M+1): dp[i][j] = dp[i-1][j] if j>=A[i][0]: k = (j-A[i][0])//(A[i][0]-A[i][1]) dp[i][j] = max(dp[i][j],dp[i-1][j-A[i][0]-k*(A[i][0]-A[i][1])]+(k+1)*A[i][1]*A[i][2]) for j in range(1,M+1): print(dp[N][j])