#include using namespace std; using ll = long long; using lll = __int128; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(ll i = 0; i < n; ++i) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a> n >> m; vector dp(m+1,0); vector> query(n); while(n--){ ll a,b,c; cin >> a >> b >> c; vector upd(m+1,-INFLL); for(int j=a;j<=m;j++) chmax(upd[j], dp[j-a]+b*c); for(int j=a-b;j<=m;j++) chmax(upd[j+a-b], upd[j]+b*c); rep(j,m+1) chmax(dp[j], upd[j]); } rep(i,m){ cout << dp[i+1] << '\n'; } return 0; }