import numpy as np



N = int(eval(input()))



values = np.array([list(map(int, input().split(' '))) for _ in range(N)])

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



dp[0] = values[0]



for i in range(1, N):

    prev = dp[i - 1]

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

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

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



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

import numpy as np



N = int(eval(input()))



values = [tuple(map(int, input().split(' '))) for _ in range(N)]

dp = [values[0]]

for _ in range(N - 1):

    dp.append([0, 0, 0])



for i in range(1, N):

    prev = dp[i - 1]

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

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

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



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

import numpy as np

N = int(eval(input()))
values = np.array([list(map(int, input().split(" "))) for _ in range(N)])
dp = np.zeros(shape=(N, 3), dtype=int)
dp[0] = values[0]
for i in range(1, N):
    prev = dp[i - 1]
    dp[i][0] = values[i][0] + max(prev[1], prev[2])
    dp[i][1] = values[i][1] + max(prev[0], prev[2])
    dp[i][2] = values[i][2] + max(prev[0], prev[1])
print((np.max(dp[N - 1])))

import numpy as np

N = int(eval(input()))
values = [tuple(map(int, input().split(" "))) for _ in range(N)]
dp = [values[0]]
for _ in range(N - 1):
    dp.append([0, 0, 0])
for i in range(1, N):
    prev = dp[i - 1]
    dp[i][0] = values[i][0] + max(prev[1], prev[2])
    dp[i][1] = values[i][1] + max(prev[0], prev[2])
    dp[i][2] = values[i][2] + max(prev[0], prev[1])
print((np.max(dp[N - 1])))

-values = np.array([list(map(int, input().split(" "))) for _ in range(N)]) -dp = np.zeros(shape=(N, 3), dtype=int) -dp[0] = values[0] +values = [tuple(map(int, input().split(" "))) for _ in range(N)] +dp = [values[0]] +for _ in range(N - 1): +    dp.append([0, 0, 0])