N=int(eval(input()))

abc=[[0 for i in range(3)] for j in range(N)]

for i in range(N):

    A=list(map(int,input().split()))

    for j in range(3):

        abc[i][j]=A[j]

dp=[[0,0,0] for i in range(N+1)]

for i in range(N):

    for j in range(3):

        buf=[]

        for h in range(3):

            if h!=j:

                buf.append(dp[i][h]+abc[i][h])

        dp[i+1][j]=max(buf)

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

import numpy as np

N=int(eval(input()))

ABC=[]

for i in range(N):

    ABC.append(list(map(int,input().split())))

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

dp[0]=ABC[0]

for i in range(1,N):

    for j in range(3):

        dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+ABC[i][j]

print((max(dp[N-1])))
N = int(eval(input()))
abc = [[0 for i in range(3)] for j in range(N)]
for i in range(N):
    A = list(map(int, input().split()))
    for j in range(3):
        abc[i][j] = A[j]
dp = [[0, 0, 0] for i in range(N + 1)]
for i in range(N):
    for j in range(3):
        buf = []
        for h in range(3):
            if h != j:
                buf.append(dp[i][h] + abc[i][h])
        dp[i + 1][j] = max(buf)
print((max(dp[N])))

import numpy as np

N = int(eval(input()))
ABC = []
for i in range(N):
    ABC.append(list(map(int, input().split())))
dp = [[0, 0, 0] for i in range(N)]
dp[0] = ABC[0]
for i in range(1, N):
    for j in range(3):
        dp[i][j] = max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + ABC[i][j]
print((max(dp[N - 1])))

+import numpy as np + -abc = [[0 for i in range(3)] for j in range(N)] +ABC = [] -    A = list(map(int, input().split())) +    ABC.append(list(map(int, input().split()))) +dp = [[0, 0, 0] for i in range(N)] +dp[0] = ABC[0] +for i in range(1, N): -        abc[i][j] = A[j] -dp = [[0, 0, 0] for i in range(N + 1)] -for i in range(N): -    for j in range(3): -        buf = [] -        for h in range(3): -            if h != j: -                buf.append(dp[i][h] + abc[i][h]) -        dp[i + 1][j] = max(buf) -print((max(dp[N]))) +        dp[i][j] = max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + ABC[i][j] +print((max(dp[N - 1])))