N=int(eval(input()))

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



for i in range(N):

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

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

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

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

  

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

import sys

readline = sys.stdin.readline



N = int(readline())

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



for i in range(N):

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

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

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

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

  

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

import sys

readline = sys.stdin.readline
N = int(readline())
dp = [[0] * 3 for i in range(N + 1)]
for i in range(N):
    a, b, c = list(map(int, readline().split()))
    dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a
    dp[i + 1][1] = max(dp[i][2], dp[i][0]) + b
    dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c
print((max(dp[N])))

-N = int(eval(input())) -dp = [[0 for i in range(3)] for j in range(N + 1)] +import sys + +readline = sys.stdin.readline +N = int(readline()) +dp = [[0] * 3 for i in range(N + 1)] -    a, b, c = list(map(int, input().split())) -    dp[i + 1][0] = max(dp[i][1] + a, dp[i][2] + a) -    dp[i + 1][1] = max(dp[i][0] + b, dp[i][2] + b) -    dp[i + 1][2] = max(dp[i][1] + c, dp[i][0] + c) +    a, b, c = list(map(int, readline().split())) +    dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a +    dp[i + 1][1] = max(dp[i][2], dp[i][0]) + b +    dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c