N = int(eval(input()))

abc = [list(map(int, input().split())) for _ in range(N)]



dp = []

for i in range(N+1):

    dp.append([0] * 3)



for j in range(1, N+1):

    for k in range(3):

        if j == 1:

            dp[j][k] = abc[0][k]

        else:

            box = []

            for l in range(3):

                if l == k:

                    continue

                else:

                    box.append(dp[j-1][l] + abc[j-1][k])

            dp[j][k] = max(dp[j][k], max(box))

print((max(dp[N])))

N = int(eval(input()))

dpa = [0] * N

dpb = [0] * N

dpc = [0] * N



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

dpa[0] = a

dpb[0] = b

dpc[0] = c

for i in range(1, N):

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

    dpa[i] = max(dpb[i-1] + a, dpc[i-1] + a)

    dpb[i] = max(dpa[i-1] + b, dpc[i-1] + b)

    dpc[i] = max(dpa[i-1] + c, dpb[i-1] + c)



print((max(dpa[N-1], dpb[N-1], dpc[N-1])))
N = int(eval(input()))
abc = [list(map(int, input().split())) for _ in range(N)]
dp = []
for i in range(N + 1):
    dp.append([0] * 3)
for j in range(1, N + 1):
    for k in range(3):
        if j == 1:
            dp[j][k] = abc[0][k]
        else:
            box = []
            for l in range(3):
                if l == k:
                    continue
                else:
                    box.append(dp[j - 1][l] + abc[j - 1][k])
            dp[j][k] = max(dp[j][k], max(box))
print((max(dp[N])))

N = int(eval(input()))
dpa = [0] * N
dpb = [0] * N
dpc = [0] * N
a, b, c = list(map(int, input().split()))
dpa[0] = a
dpb[0] = b
dpc[0] = c
for i in range(1, N):
    a, b, c = list(map(int, input().split()))
    dpa[i] = max(dpb[i - 1] + a, dpc[i - 1] + a)
    dpb[i] = max(dpa[i - 1] + b, dpc[i - 1] + b)
    dpc[i] = max(dpa[i - 1] + c, dpb[i - 1] + c)
print((max(dpa[N - 1], dpb[N - 1], dpc[N - 1])))

-abc = [list(map(int, input().split())) for _ in range(N)] -dp = [] -for i in range(N + 1): -    dp.append([0] * 3) -for j in range(1, N + 1): -    for k in range(3): -        if j == 1: -            dp[j][k] = abc[0][k] -        else: -            box = [] -            for l in range(3): -                if l == k: -                    continue -                else: -                    box.append(dp[j - 1][l] + abc[j - 1][k]) -            dp[j][k] = max(dp[j][k], max(box)) -print((max(dp[N]))) +dpa = [0] * N +dpb = [0] * N +dpc = [0] * N +a, b, c = list(map(int, input().split())) +dpa[0] = a +dpb[0] = b +dpc[0] = c +for i in range(1, N): +    a, b, c = list(map(int, input().split())) +    dpa[i] = max(dpb[i - 1] + a, dpc[i - 1] + a) +    dpb[i] = max(dpa[i - 1] + b, dpc[i - 1] + b) +    dpc[i] = max(dpa[i - 1] + c, dpb[i - 1] + c) +print((max(dpa[N - 1], dpb[N - 1], dpc[N - 1])))