local n = io.read("*n")
local c, s, f = {}, {}, {}
for i = 1, n - 1 do
  c[i], s[i], f[i] = io.read("*n", "*n", "*n")
end
local mma = math.max
for i = 1, n - 1 do
  local cur = 0
  for j = i, n - 1 do
    cur = mma(s[j], (cur // f[j]) * f[j])
    cur = cur + c[j]
  end
  print(cur)
end
print(0)