#include using namespace std; //* ATCODER #include using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template T max(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template T min(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template T sum(vector &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } int main(){ int n, m; cin >> n >> m; vector a(n), b(n), c(n); rep(i,0,n) cin >> a[i] >> b[i] >> c[i]; vector dp(m+1); vector dp_mode(m+1, vector(n)); vector seen(m+1); vector seen_mode(m+1, vector(n)); seen[0] = 1; auto calc = [&](auto self, int i, int j) -> ll { if (j == -1){ if (seen[i]) return dp[i]; ll ret = 0; rep(j,0,n){ if (i < a[j]) continue; chmax(ret, self(self, i - a[j], j) + c[j] * b[j]); } seen[i] = 1; dp[i] = ret; return ret; }else{ if (seen_mode[i][j]) return dp_mode[i][j]; ll ret = 0; if (i - a[j] + b[j] >= 0){ chmax(ret, self(self, i - a[j] + b[j], j) + c[j] * b[j]); } chmax(ret, self(self, i, -1)); seen_mode[i][j] = 1; dp_mode[i][j] = ret; return ret; } }; rep(i,1,m+1){ cout << calc(calc, i, -1) << '\n'; } }