// A cans -> B cans #include // #include #include #include using namespace std; // using namespace atcoder; // using mint = modint998244353; // using mint = modint1000000007; using vi = vector; using vvi = vector>; using ll = long long; template using max_heap = priority_queue; template using min_heap = priority_queue, greater<>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, f, n) for (int i = (int) f; i < (int)(n); i++) #define repd(i, n, l) for (int i = (int) n; i >= (int) l; i--) const ll inf = ll(1e16+7); int main() { int n, m; cin >> n >> m; vector> C; ll a, b, c; rep(i, n){ cin >> a >> b >> c; C.push_back({a, b, c}); } vector>> dp(n+1, vector>(2, vector(m+1, -inf))); dp[0][0][0] = 0; rep(i, n){ ll a = C[i][0]; ll b = C[i][1]; ll c = C[i][2]; for (int j = 0; j <= m; j++){ dp[i+1][0][j] = max(dp[i][1][j], dp[i][0][j]); } for (int j = 0; j <= m; j++){ if (j + a <= m){ dp[i+1][1][j + a] = max(dp[i+1][1][j+a], dp[i+1][0][j] + b * c); } if (j + a - b <= m){ dp[i+1][1][j + a - b] = max(dp[i+1][1][j + a - b], dp[i+1][1][j] + b * c); } } } vector A(m+1, 0); for (int i = 1; i <= m; i++){ ll ans = max(dp[n][0][i], dp[n][1][i]); ans = max(ans, A[i-1]); if (ans < 0) ans = 0; else cout << ans << endl; A[i] = ans; } return 0; }