import numpy as np

N = int(eval(input()))

dp = np.zeros((N+1, 3), dtype=int)

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((np.max(dp[-1])))
import numpy as np

N = int(eval(input()))

dp = [[0, 0, 0] for i 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((np.max(dp[-1])))
import numpy as np

N = int(eval(input()))
dp = np.zeros((N + 1, 3), dtype=int)
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((np.max(dp[-1])))

import numpy as np

N = int(eval(input()))
dp = [[0, 0, 0] for i 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((np.max(dp[-1])))

-dp = np.zeros((N + 1, 3), dtype=int) +dp = [[0, 0, 0] for i in range(N + 1)]