N = int(eval(input()))

dp = [[0] * 3 for _ in range(N)]

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

dp[0][0] = action[0]

dp[0][1] = action[1]

dp[0][2] = action[2]

for i in range(N-1):

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

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

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

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

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

dp = [[0] * 3 for _ in range(N)]

dp[0][0], dp[0][1], dp[0][2] = list(map(int, input().split()))

for i in range(1,N):

    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[N-1])))
N = int(eval(input()))
dp = [[0] * 3 for _ in range(N)]
action = list(map(int, input().split()))
dp[0][0] = action[0]
dp[0][1] = action[1]
dp[0][2] = action[2]
for i in range(N - 1):
    action = list(map(int, input().split()))
    dp[i + 1][0] = max(dp[i][1] + action[0], dp[i][2] + action[0])
    dp[i + 1][1] = max(dp[i][0] + action[1], dp[i][2] + action[1])
    dp[i + 1][2] = max(dp[i][0] + action[2], dp[i][1] + action[2])
print((max(dp[N - 1])))

N = int(eval(input()))
dp = [[0] * 3 for _ in range(N)]
dp[0][0], dp[0][1], dp[0][2] = list(map(int, input().split()))
for i in range(1, N):
    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[N - 1])))

-action = list(map(int, input().split())) -dp[0][0] = action[0] -dp[0][1] = action[1] -dp[0][2] = action[2] -for i in range(N - 1): -    action = list(map(int, input().split())) -    dp[i + 1][0] = max(dp[i][1] + action[0], dp[i][2] + action[0]) -    dp[i + 1][1] = max(dp[i][0] + action[1], dp[i][2] + action[1]) -    dp[i + 1][2] = max(dp[i][0] + action[2], dp[i][1] + action[2]) +dp[0][0], dp[0][1], dp[0][2] = list(map(int, input().split())) +for i in range(1, N): +    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)