import numpy as np

n=int(eval(input()))

H=[]

for i in range(n):

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

    H.append([a,b,c])



dp=[[0 for i in range(3)] for j in range(n+1)]



dp[0][0]=H[0][0]

dp[0][1]=H[0][1]

dp[0][2]=H[0][2]



for i in range(0,n-1):

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

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

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



print((max(dp[n-1][0],dp[n-1][1],dp[n-1][2])))
n=int(eval(input()))

H=[]

for i in range(n):

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

    H.append([a,b,c])



if n==1:

    print((max(H[0][0],H[0][1],H[0][2])))

    exit()

dp=[[0,0,0]for j in range(n)]

for i in range(3):

    dp[0][i]=H[0][i]



for i in range(0,n-1):

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

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

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



print((max(dp[n-1][0],dp[n-1][1],dp[n-1][2])))
import numpy as np

n = int(eval(input()))
H = []
for i in range(n):
    a, b, c = list(map(int, input().split()))
    H.append([a, b, c])
dp = [[0 for i in range(3)] for j in range(n + 1)]
dp[0][0] = H[0][0]
dp[0][1] = H[0][1]
dp[0][2] = H[0][2]
for i in range(0, n - 1):
    dp[i + 1][0] = max(dp[i][1], dp[i][2]) + H[i + 1][0]
    dp[i + 1][1] = max(dp[i][0], dp[i][2]) + H[i + 1][1]
    dp[i + 1][2] = max(dp[i][0], dp[i][1]) + H[i + 1][2]
print((max(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2])))

n = int(eval(input()))
H = []
for i in range(n):
    a, b, c = list(map(int, input().split()))
    H.append([a, b, c])
if n == 1:
    print((max(H[0][0], H[0][1], H[0][2])))
    exit()
dp = [[0, 0, 0] for j in range(n)]
for i in range(3):
    dp[0][i] = H[0][i]
for i in range(0, n - 1):
    dp[i + 1][0] = max(dp[i][1], dp[i][2]) + H[i + 1][0]
    dp[i + 1][1] = max(dp[i][0], dp[i][2]) + H[i + 1][1]
    dp[i + 1][2] = max(dp[i][1], dp[i][0]) + H[i + 1][2]
print((max(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2])))

-import numpy as np - -dp = [[0 for i in range(3)] for j in range(n + 1)] -dp[0][0] = H[0][0] -dp[0][1] = H[0][1] -dp[0][2] = H[0][2] +if n == 1: +    print((max(H[0][0], H[0][1], H[0][2]))) +    exit() +dp = [[0, 0, 0] for j in range(n)] +for i in range(3): +    dp[0][i] = H[0][i] -    dp[i + 1][2] = max(dp[i][0], dp[i][1]) + H[i + 1][2] +    dp[i + 1][2] = max(dp[i][1], dp[i][0]) + H[i + 1][2]