N = int(eval(input()))

dp = [[0 for _ in range(3)] for i in range(N)]

a,b,c = list(map(int,input().split()))

dpa = a

dpb = b

dpc = c

for i in range(1,N):

    dpap = dpa

    dpbp = dpb

    dpcp = dpc

    a,b,c = list(map(int,input().split()))

    dpa = max(dpbp + a, dpcp + a)

    dpb = max(dpap + b, dpcp + b)

    dpc = max(dpap + c, dpbp + c)

print((max(dpa,dpb,dpc)))



N = int(eval(input()))

a,b,c = list(map(int,input().split()))

dpa = a

dpb = b

dpc = c

for i in range(1,N):

    dpap = dpa

    dpbp = dpb

    dpcp = dpc

    a,b,c = list(map(int,input().split()))

    dpa = max(dpbp + a, dpcp + a)

    dpb = max(dpap + b, dpcp + b)

    dpc = max(dpap + c, dpbp + c)

print((max(dpa,dpb,dpc)))



N = int(eval(input()))
dp = [[0 for _ in range(3)] for i in range(N)]
a, b, c = list(map(int, input().split()))
dpa = a
dpb = b
dpc = c
for i in range(1, N):
    dpap = dpa
    dpbp = dpb
    dpcp = dpc
    a, b, c = list(map(int, input().split()))
    dpa = max(dpbp + a, dpcp + a)
    dpb = max(dpap + b, dpcp + b)
    dpc = max(dpap + c, dpbp + c)
print((max(dpa, dpb, dpc)))

N = int(eval(input()))
a, b, c = list(map(int, input().split()))
dpa = a
dpb = b
dpc = c
for i in range(1, N):
    dpap = dpa
    dpbp = dpb
    dpcp = dpc
    a, b, c = list(map(int, input().split()))
    dpa = max(dpbp + a, dpcp + a)
    dpb = max(dpap + b, dpcp + b)
    dpc = max(dpap + c, dpbp + c)
print((max(dpa, dpb, dpc)))

-dp = [[0 for _ in range(3)] for i in range(N)]