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])))
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((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])))

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((max(dp[-1])))

-import numpy as np - -print((np.max(dp[-1]))) +print((max(dp[-1])))