import sys

N = int(eval(input()))

A = [0] * N

B = [0] * N

C = [0] * N

for i, e in enumerate(sys.stdin):

    A[i], B[i], C[i] = list(map(int, e.split()))

dp = [[0] * 3 for _ in range(N + 1)]

for i in range(N):

    dp[i][0] = max(dp[i - 1][1] + A[i], dp[i - 1][2] + A[i])

    dp[i][1] = max(dp[i - 1][0] + B[i], dp[i - 1][2] + B[i])

    dp[i][2] = max(dp[i - 1][0] + C[i], dp[i - 1][1] + C[i])

print((max(dp[N - 1])))
import sys

N = int(eval(input()))

x, y, z = 0, 0, 0

for i, e in enumerate(sys.stdin):

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

    nx = max(y, z) + a

    ny = max(x, z) + b

    nz = max(x, y) + c

    x, y, z = nx, ny, nz

print((max(x, y, z)))
import sys

N = int(eval(input()))
A = [0] * N
B = [0] * N
C = [0] * N
for i, e in enumerate(sys.stdin):
    A[i], B[i], C[i] = list(map(int, e.split()))
dp = [[0] * 3 for _ in range(N + 1)]
for i in range(N):
    dp[i][0] = max(dp[i - 1][1] + A[i], dp[i - 1][2] + A[i])
    dp[i][1] = max(dp[i - 1][0] + B[i], dp[i - 1][2] + B[i])
    dp[i][2] = max(dp[i - 1][0] + C[i], dp[i - 1][1] + C[i])
print((max(dp[N - 1])))

import sys

N = int(eval(input()))
x, y, z = 0, 0, 0
for i, e in enumerate(sys.stdin):
    a, b, c = list(map(int, e.split()))
    nx = max(y, z) + a
    ny = max(x, z) + b
    nz = max(x, y) + c
    x, y, z = nx, ny, nz
print((max(x, y, z)))

-A = [0] * N -B = [0] * N -C = [0] * N +x, y, z = 0, 0, 0 -    A[i], B[i], C[i] = list(map(int, e.split())) -dp = [[0] * 3 for _ in range(N + 1)] -for i in range(N): -    dp[i][0] = max(dp[i - 1][1] + A[i], dp[i - 1][2] + A[i]) -    dp[i][1] = max(dp[i - 1][0] + B[i], dp[i - 1][2] + B[i]) -    dp[i][2] = max(dp[i - 1][0] + C[i], dp[i - 1][1] + C[i]) -print((max(dp[N - 1]))) +    a, b, c = list(map(int, e.split())) +    nx = max(y, z) + a +    ny = max(x, z) + b +    nz = max(x, y) + c +    x, y, z = nx, ny, nz +print((max(x, y, z)))