#include #include #define pass (void)0 #define INF (1<<30)-1 #define INFLL (1LL<<60)-1 using namespace std; using namespace atcoder; using mint = modint998244353; using ll = long long; int main() { int N, M; cin >> N >> M; vector> can(N); for (int i = 0; i < N; ++i) { ll A, B, C; cin >> A >> B >> C; can[i] = make_tuple(A, B, C); } vector> dp(N+1, vector(M+1, -INF)); dp[0][0] = 0; for (int i = 0; i < N; ++i) { ll A = get<0>(can[i]); ll B = get<1>(can[i]); ll C = get<2>(can[i]); ll first = A; ll second = A - B; for (int j = 0; j <= M; ++j) { if (dp[i+1][j] != -INF && 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 (int i = 1; i <= M; ++i) { dp[N][i] = max(dp[N][i], dp[N][i-1]); } for (int i = 1; i <= M; ++i) { cout << dp[N][i] << "\n"; } return 0; }