"C Vacation"

N = int(eval(input()))

summer = []

for i in range(N):

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

    summer.append(active)



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

# dp = [[0, 0, 0]] * (N+1)



# print(dp)

for i in range(N):

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

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

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



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

N = int(eval(input()))

S = [list(map(int, input().split())) for _ in range(N)]  # N日間の夏休み



dp = [[0]*3 for _ in range(N)]  # i日目の状態, (幸福度の合計, 前日の遊んだ内容3種類のテーブル)



# print(S)

# print(dp)



# 初期値

dp[0][0] = (S[0][0], 'a')

dp[0][1] = (S[0][1], 'b')

dp[0][2] = (S[0][2], 'c')



# print(dp)

for i in range(1, N):  # N日間の遷移

    # aの予定を実行する場合

    if dp[i-1][1][0]+S[i][0] > dp[i-1][2][0]+S[i][0]:

        dp[i][0] = (dp[i-1][1][0]+S[i][0], 'a')

    else:

        dp[i][0] = (dp[i-1][2][0]+S[i][0], 'a')



    # bの予定を実行する場合

    if dp[i-1][0][0]+S[i][1] > dp[i-1][2][0]+S[i][1]:

        dp[i][1] = (dp[i-1][0][0]+S[i][1], 'b')

    else:

        dp[i][1] = (dp[i-1][2][0]+S[i][1], 'b')



    # cの予定を実行する場合

    if dp[i-1][0][0]+S[i][2] > dp[i-1][1][0]+S[i][2]:

        dp[i][2] = (dp[i-1][0][0]+S[i][2], 'c')

    else:

        dp[i][2] = (dp[i-1][1][0]+S[i][2], 'c')



# print(dp)

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

"C Vacation"
N = int(eval(input()))
summer = []
for i in range(N):
    active = list(map(int, input().split()))
    summer.append(active)
dp = [[0] * 3 for i in range(N + 1)]
# dp = [[0, 0, 0]] * (N+1)
# print(dp)
for i in range(N):
    dp[i + 1][0] = max((max(dp[i][1], dp[i][2]) + summer[i][0]), dp[i + 1][0])
    dp[i + 1][1] = max((max(dp[i][0], dp[i][2]) + summer[i][1]), dp[i + 1][1])
    dp[i + 1][2] = max((max(dp[i][0], dp[i][1]) + summer[i][2]), dp[i + 1][2])
print((max(dp[-1])))

N = int(eval(input()))
S = [list(map(int, input().split())) for _ in range(N)]  # N日間の夏休み
dp = [[0] * 3 for _ in range(N)]  # i日目の状態, (幸福度の合計, 前日の遊んだ内容3種類のテーブル)
# print(S)
# print(dp)
# 初期値
dp[0][0] = (S[0][0], "a")
dp[0][1] = (S[0][1], "b")
dp[0][2] = (S[0][2], "c")
# print(dp)
for i in range(1, N):  # N日間の遷移
    # aの予定を実行する場合
    if dp[i - 1][1][0] + S[i][0] > dp[i - 1][2][0] + S[i][0]:
        dp[i][0] = (dp[i - 1][1][0] + S[i][0], "a")
    else:
        dp[i][0] = (dp[i - 1][2][0] + S[i][0], "a")
    # bの予定を実行する場合
    if dp[i - 1][0][0] + S[i][1] > dp[i - 1][2][0] + S[i][1]:
        dp[i][1] = (dp[i - 1][0][0] + S[i][1], "b")
    else:
        dp[i][1] = (dp[i - 1][2][0] + S[i][1], "b")
    # cの予定を実行する場合
    if dp[i - 1][0][0] + S[i][2] > dp[i - 1][1][0] + S[i][2]:
        dp[i][2] = (dp[i - 1][0][0] + S[i][2], "c")
    else:
        dp[i][2] = (dp[i - 1][1][0] + S[i][2], "c")
# print(dp)
print((max(dp[N - 1])[0]))

-"C Vacation" -summer = [] -for i in range(N): -    active = list(map(int, input().split())) -    summer.append(active) -dp = [[0] * 3 for i in range(N + 1)] -# dp = [[0, 0, 0]] * (N+1) +S = [list(map(int, input().split())) for _ in range(N)]  # N日間の夏休み +dp = [[0] * 3 for _ in range(N)]  # i日目の状態, (幸福度の合計, 前日の遊んだ内容3種類のテーブル) +# print(S) -for i in range(N): -    dp[i + 1][0] = max((max(dp[i][1], dp[i][2]) + summer[i][0]), dp[i + 1][0]) -    dp[i + 1][1] = max((max(dp[i][0], dp[i][2]) + summer[i][1]), dp[i + 1][1]) -    dp[i + 1][2] = max((max(dp[i][0], dp[i][1]) + summer[i][2]), dp[i + 1][2]) -print((max(dp[-1]))) +# 初期値 +dp[0][0] = (S[0][0], "a") +dp[0][1] = (S[0][1], "b") +dp[0][2] = (S[0][2], "c") +# print(dp) +for i in range(1, N):  # N日間の遷移 +    # aの予定を実行する場合 +    if dp[i - 1][1][0] + S[i][0] > dp[i - 1][2][0] + S[i][0]: +        dp[i][0] = (dp[i - 1][1][0] + S[i][0], "a") +    else: +        dp[i][0] = (dp[i - 1][2][0] + S[i][0], "a") +    # bの予定を実行する場合 +    if dp[i - 1][0][0] + S[i][1] > dp[i - 1][2][0] + S[i][1]: +        dp[i][1] = (dp[i - 1][0][0] + S[i][1], "b") +    else: +        dp[i][1] = (dp[i - 1][2][0] + S[i][1], "b") +    # cの予定を実行する場合 +    if dp[i - 1][0][0] + S[i][2] > dp[i - 1][1][0] + S[i][2]: +        dp[i][2] = (dp[i - 1][0][0] + S[i][2], "c") +    else: +        dp[i][2] = (dp[i - 1][1][0] + S[i][2], "c") +# print(dp) +print((max(dp[N - 1])[0]))