# coding: utf-8

import numpy as np



n = int(eval(input()))

dp = np.zeros((n+10, 3))



def cmax(a,b):

    if a>b:

        return a

    else: 

        return b

        

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

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

    # a

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

    # b

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

    # c

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



print((int(max(dp[i,:]))))
# coding: utf-8

# Your code here!





N = int(eval(input()))



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], dp[i-1][2]) + a

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

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

    

print((max(dp[N])))
# coding: utf-8
import numpy as np

n = int(eval(input()))
dp = np.zeros((n + 10, 3))


def cmax(a, b):
    if a > b:
        return a
    else:
        return b


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

# coding: utf-8
# Your code here!
N = int(eval(input()))
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], dp[i - 1][2]) + a
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c
print((max(dp[N])))

-import numpy as np - -n = int(eval(input())) -dp = np.zeros((n + 10, 3)) - - -def cmax(a, b): -    if a > b: -        return a -    else: -        return b - - -for i in range(1, n + 1): +# Your code here! +N = int(eval(input())) +dp = [[0] * 3 for _ in range(N + 1)] +for i in range(1, N + 1): -    # a -    dp[i][0] = cmax(dp[i - 1][1] + a, dp[i - 1][2] + a) -    # b -    dp[i][1] = cmax(dp[i - 1][0] + b, dp[i - 1][2] + b) -    # c -    dp[i][2] = cmax(dp[i - 1][0] + c, dp[i - 1][1] + c) -print((int(max(dp[i, :])))) +    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a +    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b +    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c +print((max(dp[N])))