N = int(eval(input()))

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



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

dp[0][0] = abc[0][0]

dp[0][1] = abc[0][1]

dp[0][2] = abc[0][2]



for i in range(1, N):

    for j in range(3):

        for k in range(3):

            if j == k:

                continue

            dpp = dp[i - 1][j] + abc[i][k]

            dp[i][k] = max(dp[i][k], dpp)



print((max(dp[-1])))
N = int(eval(input()))

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

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

dp[0][0] = 0

dp[0][1] = 0

dp[0][2] = 0

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

    for j in range(3):

        for k in range(3):

            if j == k:

                continue

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

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

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

-dp = [[0] * 3 for _ in range(N)] -dp[0][0] = abc[0][0] -dp[0][1] = abc[0][1] -dp[0][2] = abc[0][2] -for i in range(1, N): +dp = [[0] * 3 for _ in range(N + 1)] +dp[0][0] = 0 +dp[0][1] = 0 +dp[0][2] = 0 +for i in range(1, N + 1): -            dpp = dp[i - 1][j] + abc[i][k] -            dp[i][k] = max(dp[i][k], dpp) +            dp[i][j] = max(dp[i][j], dp[i - 1][k] + abc[i - 1][j])