n = int(eval(input()))

ABC = [list(map(int, input().split())) for i in range(n)]



# i日目にjを選択した後の幸福度 dp[i][j]

dp = [[0 for j in range(3)] for i 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] + ABC[i][k])



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

import sys





def input():

    return sys.stdin.readline().strip()





n = int(eval(input()))

ABC = [list(map(int, input().split())) for i in range(n)]



# i日目にjを選択した後の幸福度 dp[i][j]

dp = [[0 for j in range(3)] for i 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] + ABC[i][k])



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

n = int(eval(input()))
ABC = [list(map(int, input().split())) for i in range(n)]
# i日目にjを選択した後の幸福度 dp[i][j]
dp = [[0 for j in range(3)] for i 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] + ABC[i][k])
print((max(dp[-1])))

import sys


def input():
    return sys.stdin.readline().strip()


n = int(eval(input()))
ABC = [list(map(int, input().split())) for i in range(n)]
# i日目にjを選択した後の幸福度 dp[i][j]
dp = [[0 for j in range(3)] for i 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] + ABC[i][k])
print((max(dp[-1])))

+import sys + + +def input(): +    return sys.stdin.readline().strip() + +