n = int(eval(input()))

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



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



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

    for j in range(3):

        for k in range(3):

            if j == k:

                continue

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



ans = 0

for i in range(3):

    ans = max(ans,dp[n][i])

print(ans)
n = int(eval(input()))

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



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



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

    for j in range(3):

        for k in range(3):

            if j == k:

                continue

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



ans = max(dp[-1])

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

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

-ans = 0 -for i in range(3): -    ans = max(ans, dp[n][i]) +ans = max(dp[-1])