using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, m) = (c[0], c[1]); var map = NArr(n); WriteLine(Cans(n, m, map)); } static string Cans(int n, int m, int[][] map) { var dp = Enumerable.Repeat(long.MinValue, m + 1).ToArray(); dp[0] = 0; for (var i = 0; i < n; ++i) { var ndp = (long[]) dp.Clone(); for (var j = 0; j + map[i][0] <= m; ++j) { var add = (long)map[i][1] * map[i][2]; if (ndp[j + map[i][1]] >= 0) ndp[j + map[i][0]] = Math.Max(ndp[j + map[i][0]], ndp[j + map[i][1]] + add); if (dp[j] >= 0) ndp[j + map[i][0]] = Math.Max(ndp[j + map[i][0]], dp[j] + add); } dp = ndp; } for (var i = 1; i < dp.Length; ++i) dp[i] = Math.Max(dp[i], dp[i - 1]); return string.Join("\n", dp.Skip(1)); } }