import numpy as np



N = int(eval(input()))

a = np.array([input().split() for i in range(N)], dtype=int)



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

dp[0] = a[0]



for i in range(1, N):

    dp[i] = [

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

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

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

    ]



print((np.max(dp[-1])))

N = int(eval(input()))

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



dp = [[0, 0, 0] for _ in range(N+1)]



for i in range(N):

    for j in range(3):

        for k in range(3):

            if j == k:

                continue

            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k])



print((max(dp[-1])))

import numpy as np

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

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

-import numpy as np - -a = np.array([input().split() for i in range(N)], dtype=int) -dp = np.zeros((N, 3), dtype=int) -dp[0] = a[0] -for i in range(1, N): -    dp[i] = [ -        a[i][0] + max(dp[i - 1][1], dp[i - 1][2]), -        a[i][1] + max(dp[i - 1][2], dp[i - 1][0]), -        a[i][2] + max(dp[i - 1][0], dp[i - 1][1]), -    ] -print((np.max(dp[-1]))) +a = [list(map(int, input().split())) for _ in range(N)] +dp = [[0, 0, 0] for _ in range(N + 1)] +for i in range(N): +    for j in range(3): +        for k in range(3): +            if j == k: +                continue +            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k]) +print((max(dp[-1])))