N = int(eval(input()))

ABC = [[None]*3 for i in range(N)]



for i in range(N):

    ABC[i][0], ABC[i][1], ABC[i][2] = list(map(int, input().split()))



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



for i in range(N):

    for j in range(3):

        happiness[i+1][j] = max(happiness[i][j-1] + ABC[i][j], happiness[i][j-2] + ABC[i][j])



print((max(happiness[N])))
import sys



N = int(sys.stdin.readline())

ABC = [[None]*3 for i in range(N)]



for i in range(N):

    ABC[i][0], ABC[i][1], ABC[i][2] = list(map(int, sys.stdin.readline().split()))



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



for i in range(N):

    for j in range(3):

        happiness[i+1][j] = max(happiness[i][j-1] + ABC[i][j], happiness[i][j-2] + ABC[i][j])



print((max(happiness[N])))
N = int(eval(input()))
ABC = [[None] * 3 for i in range(N)]
for i in range(N):
    ABC[i][0], ABC[i][1], ABC[i][2] = list(map(int, input().split()))
happiness = [[0] * 3 for i in range(N + 1)]
for i in range(N):
    for j in range(3):
        happiness[i + 1][j] = max(
            happiness[i][j - 1] + ABC[i][j], happiness[i][j - 2] + ABC[i][j]
        )
print((max(happiness[N])))

import sys

N = int(sys.stdin.readline())
ABC = [[None] * 3 for i in range(N)]
for i in range(N):
    ABC[i][0], ABC[i][1], ABC[i][2] = list(map(int, sys.stdin.readline().split()))
happiness = [[0] * 3 for i in range(N + 1)]
for i in range(N):
    for j in range(3):
        happiness[i + 1][j] = max(
            happiness[i][j - 1] + ABC[i][j], happiness[i][j - 2] + ABC[i][j]
        )
print((max(happiness[N])))

-N = int(eval(input())) +import sys + +N = int(sys.stdin.readline()) -    ABC[i][0], ABC[i][1], ABC[i][2] = list(map(int, input().split())) +    ABC[i][0], ABC[i][1], ABC[i][2] = list(map(int, sys.stdin.readline().split()))