import numpy as np

N = int(eval(input()))



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



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



for i in range(1, N+1):

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

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

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



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

N = int(eval(input()))



A = [0] * (N + 1)

B = [0] * (N + 1)

C = [0] * (N + 1)



for i in range(1, N + 1):

    A[i], B[i], C[i] = list(map(int, input().split()))



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

for i in range(1, N + 1):

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

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

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



print((max(dp[N])))
import numpy as np

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

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

-import numpy as np - -abc = np.array([list(map(int, input().split())) for i in range(N)]) -dp = [[0] * 3 for i in range(N + 1)] +A = [0] * (N + 1) +B = [0] * (N + 1) +C = [0] * (N + 1) -    dp[i][0] = max(dp[i - 1][1] + abc[i - 1][1], dp[i - 1][2] + abc[i - 1][2]) -    dp[i][1] = max(dp[i - 1][0] + abc[i - 1][0], dp[i - 1][2] + abc[i - 1][2]) -    dp[i][2] = max(dp[i - 1][1] + abc[i - 1][1], dp[i - 1][0] + abc[i - 1][0]) -print((max(dp[-1]))) +    A[i], B[i], C[i] = list(map(int, input().split())) +dp = [[0] * 3 for _ in range(N + 1)] +for i in range(1, N + 1): +    dp[i][0] = A[i] + max(dp[i - 1][1], dp[i - 1][2]) +    dp[i][1] = B[i] + max(dp[i - 1][2], dp[i - 1][0]) +    dp[i][2] = C[i] + max(dp[i - 1][0], dp[i - 1][1]) +print((max(dp[N])))