import sys

## io

IS = lambda: sys.stdin.readline().rstrip()

II = lambda: int(IS())

MII = lambda: list(map(int, IS().split()))

MIIZ = lambda: list([x-1 for x in MII()])

## dp

INIT_VAL = 0

MD2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]

MD3 = lambda d1,d2,d3: [MD2(d2,d3) for _ in range(d1)]

## math

DIVC = lambda x,y: -(-x//y)

DIVF = lambda x,y: x//y

from collections import namedtuple



def main():

    n = II()

    tt = [MII() for _ in range(n-1)]

    for i in range(n-1):

        t = 0

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

            c, s, f = tt[j]

            # 待ち時間の計算

            if t <= s:

                t = s

            elif t%f == 0:

                pass

            else:

                t += f - (t%f)

            # 電車移動時間を加算

            t += c

            pass

        print(t)

    print((0))





if __name__ == '__main__':

    main()
import sys

## io

IS = lambda: sys.stdin.readline().rstrip()

II = lambda: int(IS())

MII = lambda: list(map(int, IS().split()))

MIIZ = lambda: list([x-1 for x in MII()])

## dp

INIT_VAL = 0

MD2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]

MD3 = lambda d1,d2,d3: [MD2(d2,d3) for _ in range(d1)]

## math

DIVC = lambda x,y: -(-x//y)

DIVF = lambda x,y: x//y





def main():

    n = II()

    tt = [MII() for _ in range(n-1)]

    for i in range(n):

        t = 0

        for c, s, f in tt[i:]:

            # 待ち時間の計算

            if t <= s:

                t = s

            elif t%f == 0:

                pass

            else:

                t += f - (t%f)

            # 電車移動時間を加算

            t += c

        print(t)





if __name__ == '__main__':

    main()
import sys

## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list([x - 1 for x in MII()])
## dp
INIT_VAL = 0
MD2 = lambda d1, d2: [[INIT_VAL] * d2 for _ in range(d1)]
MD3 = lambda d1, d2, d3: [MD2(d2, d3) for _ in range(d1)]
## math
DIVC = lambda x, y: -(-x // y)
DIVF = lambda x, y: x // y
from collections import namedtuple


def main():
    n = II()
    tt = [MII() for _ in range(n - 1)]
    for i in range(n - 1):
        t = 0
        for j in range(i, n - 1):
            c, s, f = tt[j]
            # 待ち時間の計算
            if t <= s:
                t = s
            elif t % f == 0:
                pass
            else:
                t += f - (t % f)
            # 電車移動時間を加算
            t += c
            pass
        print(t)
    print((0))


if __name__ == "__main__":
    main()

import sys

## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list([x - 1 for x in MII()])
## dp
INIT_VAL = 0
MD2 = lambda d1, d2: [[INIT_VAL] * d2 for _ in range(d1)]
MD3 = lambda d1, d2, d3: [MD2(d2, d3) for _ in range(d1)]
## math
DIVC = lambda x, y: -(-x // y)
DIVF = lambda x, y: x // y


def main():
    n = II()
    tt = [MII() for _ in range(n - 1)]
    for i in range(n):
        t = 0
        for c, s, f in tt[i:]:
            # 待ち時間の計算
            if t <= s:
                t = s
            elif t % f == 0:
                pass
            else:
                t += f - (t % f)
            # 電車移動時間を加算
            t += c
        print(t)


if __name__ == "__main__":
    main()

-from collections import namedtuple -    for i in range(n - 1): +    for i in range(n): -        for j in range(i, n - 1): -            c, s, f = tt[j] +        for c, s, f in tt[i:]: -            pass -    print((0))