def inpl(): return list(map(int, input().split()))

N = int(eval(input()))

A, B, C = [0]*N, [0]*N, [0]*N



for i in range(N):

    A[i], B[i], C[i] = inpl()



DP = [[0]*3 for _ in range(N)]

DP[0] = [A[0], B[0], C[0]]



for i in range(1, 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[-1])))
def inpl(): return list(map(int, input().split()))

N = int(eval(input()))

sa, sb, sc = 0, 0, 0

for i in range(N):

    a, b, c = inpl()

    sa, sb, sc = max(sb+a, sc+a), max(sa+b, sc+b), max(sa+c, sb+c)

print((max(sa, sb, sc)))

def inpl():
    return list(map(int, input().split()))


N = int(eval(input()))
A, B, C = [0] * N, [0] * N, [0] * N
for i in range(N):
    A[i], B[i], C[i] = inpl()
DP = [[0] * 3 for _ in range(N)]
DP[0] = [A[0], B[0], C[0]]
for i in range(1, 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[-1])))

def inpl():
    return list(map(int, input().split()))


N = int(eval(input()))
sa, sb, sc = 0, 0, 0
for i in range(N):
    a, b, c = inpl()
    sa, sb, sc = max(sb + a, sc + a), max(sa + b, sc + b), max(sa + c, sb + c)
print((max(sa, sb, sc)))

-A, B, C = [0] * N, [0] * N, [0] * N +sa, sb, sc = 0, 0, 0 -    A[i], B[i], C[i] = inpl() -DP = [[0] * 3 for _ in range(N)] -DP[0] = [A[0], B[0], C[0]] -for i in range(1, 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[-1]))) +    a, b, c = inpl() +    sa, sb, sc = max(sb + a, sc + a), max(sa + b, sc + b), max(sa + c, sb + c) +print((max(sa, sb, sc)))