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

n=s[0]

dp=[[0]*3 for i in range(n)]

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

dp[0][0]=s[0]

dp[0][1] = s[1]

dp[0][2] = s[2]

for i in range(1,n):

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

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

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

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

print((max(dp[n-1])))


n=list(map(int,input().split()))[0]



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

for i in range(1,n+1):

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

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

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

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

print((max(dp[-1])))
s = list(map(int, input().split()))
n = s[0]
dp = [[0] * 3 for i in range(n)]
s = list(map(int, input().split()))
dp[0][0] = s[0]
dp[0][1] = s[1]
dp[0][2] = s[2]
for i in range(1, n):
    s = list(map(int, input().split()))
    dp[i][0] = max(dp[i - 1][1] + s[0], dp[i - 1][2] + s[0])
    dp[i][1] = max(dp[i - 1][0] + s[1], dp[i - 1][2] + s[1])
    dp[i][2] = max(dp[i - 1][0] + s[2], dp[i - 1][1] + s[2])
print((max(dp[n - 1])))

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

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