#include using namespace std; #include using mint = atcoder::modint998244353; #define int long long signed main() { int n,m; cin >> n >> m; vector a(n),b(n),v(n); for(int i = 0; i < n; i++) cin >> a[i] >> b[i] >> v[i]; vector dp(m+1,0); for(int i = 1; i <= m; i++) { for(int j = 0; j < n; j++) { if(i-a[j] >= 0) { dp[i] = max(dp[i],dp[(i-a[j])%(a[j]-b[j])]+v[j]*b[j]*((i-a[j])/(a[j]-b[j])+1)); } } cout << dp[i] << endl; } }