import numpy as np

N = int(eval(input()))

L = [list(map(int, input().split())) for i in range(N)]

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



for i in range(N):

    dp[i][0] = L[0][0] if i == 0 else max(dp[i-1][1]+L[i][0], dp[i-1][2]+L[i][0])

    dp[i][1] = L[0][1] if i == 0 else max(dp[i-1][0]+L[i][1], dp[i-1][2]+L[i][1])

    dp[i][2] = L[0][2] if i == 0 else max(dp[i-1][0]+L[i][2], dp[i-1][1]+L[i][2])



print((max(dp[-1])))
N = int(eval(input()))

abc = [list(map(int, input().split())) for i in range(N)]

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

for i in range(N):

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

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

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

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

N = int(eval(input()))
L = [list(map(int, input().split())) for i in range(N)]
dp = np.zeros((N, 3), dtype=int)
for i in range(N):
    dp[i][0] = (
        L[0][0] if i == 0 else max(dp[i - 1][1] + L[i][0], dp[i - 1][2] + L[i][0])
    )
    dp[i][1] = (
        L[0][1] if i == 0 else max(dp[i - 1][0] + L[i][1], dp[i - 1][2] + L[i][1])
    )
    dp[i][2] = (
        L[0][2] if i == 0 else max(dp[i - 1][0] + L[i][2], dp[i - 1][1] + L[i][2])
    )
print((max(dp[-1])))

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

-import numpy as np - -L = [list(map(int, input().split())) for i in range(N)] -dp = np.zeros((N, 3), dtype=int) +abc = [list(map(int, input().split())) for i in range(N)] +dp = [[0 for i in range(3)] for j in range(N + 1)] -    dp[i][0] = ( -        L[0][0] if i == 0 else max(dp[i - 1][1] + L[i][0], dp[i - 1][2] + L[i][0]) -    ) -    dp[i][1] = ( -        L[0][1] if i == 0 else max(dp[i - 1][0] + L[i][1], dp[i - 1][2] + L[i][1]) -    ) -    dp[i][2] = ( -        L[0][2] if i == 0 else max(dp[i - 1][0] + L[i][2], dp[i - 1][1] + L[i][2]) -    ) +    dp[i + 1][0] = max(dp[i][1] + abc[i][0], dp[i][2] + abc[i][0]) +    dp[i + 1][1] = max(dp[i][0] + abc[i][1], dp[i][2] + abc[i][1]) +    dp[i + 1][2] = max(dp[i][0] + abc[i][2], dp[i][1] + abc[i][2])