n = int(eval(input()))

cs, ss, fs = [], [], []

for _ in range(n - 1):

    c, s, f = list(map(int, input().split()))

    cs.append(c)

    ss.append(s)

    fs.append(f)

cs.append(0)

ss.append(0)

fs.append(1)



res = []

for i in range(n - 1):

    arrives = [0]

    lefts = [ss[i]]

    for j in range(i, n - 1):

        a = lefts[-1] + cs[j]

        arrives.append(a)

        ns = ss[j + 1]

        if a > ss[j + 1]:

            nf = fs[j + 1]

            w = (nf - (a - ns) % nf) % nf

            lefts.append(a + w)

        else:

            lefts.append(ns)

    res.append(arrives[-1])

res.append(0)

for x in res:

    print(x)
n = int(eval(input()))

cs, ss, fs = [], [], []

for _ in range(n - 1):

    c, s, f = list(map(int, input().split()))

    cs.append(c)

    ss.append(s)

    fs.append(f)

cs.append(0)

ss.append(0)

fs.append(1)



res = []

for i in range(n - 1):

    t = 0

    for j in range(i, n - 1):

        s = ss[j]

        f = fs[j]

        if t < s:

            t = s

        elif t % f > 0:

            t += f - t % f

        t += cs[j]

    res.append(t)

res.append(0)

for x in res:

    print(x)
n = int(eval(input()))
cs, ss, fs = [], [], []
for _ in range(n - 1):
    c, s, f = list(map(int, input().split()))
    cs.append(c)
    ss.append(s)
    fs.append(f)
cs.append(0)
ss.append(0)
fs.append(1)
res = []
for i in range(n - 1):
    arrives = [0]
    lefts = [ss[i]]
    for j in range(i, n - 1):
        a = lefts[-1] + cs[j]
        arrives.append(a)
        ns = ss[j + 1]
        if a > ss[j + 1]:
            nf = fs[j + 1]
            w = (nf - (a - ns) % nf) % nf
            lefts.append(a + w)
        else:
            lefts.append(ns)
    res.append(arrives[-1])
res.append(0)
for x in res:
    print(x)

n = int(eval(input()))
cs, ss, fs = [], [], []
for _ in range(n - 1):
    c, s, f = list(map(int, input().split()))
    cs.append(c)
    ss.append(s)
    fs.append(f)
cs.append(0)
ss.append(0)
fs.append(1)
res = []
for i in range(n - 1):
    t = 0
    for j in range(i, n - 1):
        s = ss[j]
        f = fs[j]
        if t < s:
            t = s
        elif t % f > 0:
            t += f - t % f
        t += cs[j]
    res.append(t)
res.append(0)
for x in res:
    print(x)

-    arrives = [0] -    lefts = [ss[i]] +    t = 0 -        a = lefts[-1] + cs[j] -        arrives.append(a) -        ns = ss[j + 1] -        if a > ss[j + 1]: -            nf = fs[j + 1] -            w = (nf - (a - ns) % nf) % nf -            lefts.append(a + w) -        else: -            lefts.append(ns) -    res.append(arrives[-1]) +        s = ss[j] +        f = fs[j] +        if t < s: +            t = s +        elif t % f > 0: +            t += f - t % f +        t += cs[j] +    res.append(t)