n = int(eval(input()))

a =[0]*n

b = [0]*n

c = [0]*n

for i in range(n):

    a[i], b[i], c[i] = list(map(int, input().split()))



# dp[日にち][0:a 1:b 2:c]

dp = [[0]*3 for _i in range(n)]

dp[0] = [a[0], b[0], c[0]]

#print(dp)

for i in range(n-1):

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

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

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

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

n = int(eval(input()))

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



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

#dp[i][a] := i日目にaするときの、i日目までの幸福度の最大値

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

    dp[i][0] = max(dp[i-1][1] + abc[i-1][0],

                   dp[i-1][2] + abc[i-1][0])

    dp[i][1] = max(dp[i-1][0] + abc[i-1][1],

                   dp[i-1][2] + abc[i-1][1])

    dp[i][2] = max(dp[i-1][0] + abc[i-1][2],

                   dp[i-1][1] + abc[i-1][2])

print((max(dp[n])))

n = int(eval(input()))
a = [0] * n
b = [0] * n
c = [0] * n
for i in range(n):
    a[i], b[i], c[i] = list(map(int, input().split()))
# dp[日にち][0:a 1:b 2:c]
dp = [[0] * 3 for _i in range(n)]
dp[0] = [a[0], b[0], c[0]]
# print(dp)
for i in range(n - 1):
    dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i + 1]
    dp[i + 1][1] = max(dp[i][0], dp[i][2]) + b[i + 1]
    dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c[i + 1]
print((max(dp[n - 1])))

n = int(eval(input()))
abc = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * 3 for _ in range(n + 1)]
# dp[i][a] := i日目にaするときの、i日目までの幸福度の最大値
for i in range(1, n + 1):
    dp[i][0] = max(dp[i - 1][1] + abc[i - 1][0], dp[i - 1][2] + abc[i - 1][0])
    dp[i][1] = max(dp[i - 1][0] + abc[i - 1][1], dp[i - 1][2] + abc[i - 1][1])
    dp[i][2] = max(dp[i - 1][0] + abc[i - 1][2], dp[i - 1][1] + abc[i - 1][2])
print((max(dp[n])))

-a = [0] * n -b = [0] * n -c = [0] * n -for i in range(n): -    a[i], b[i], c[i] = list(map(int, input().split())) -# dp[日にち][0:a 1:b 2:c] -dp = [[0] * 3 for _i in range(n)] -dp[0] = [a[0], b[0], c[0]] -# print(dp) -for i in range(n - 1): -    dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i + 1] -    dp[i + 1][1] = max(dp[i][0], dp[i][2]) + b[i + 1] -    dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c[i + 1] -print((max(dp[n - 1]))) +abc = [list(map(int, input().split())) for _ in range(n)] +dp = [[0] * 3 for _ in range(n + 1)] +# dp[i][a] := i日目にaするときの、i日目までの幸福度の最大値 +for i in range(1, n + 1): +    dp[i][0] = max(dp[i - 1][1] + abc[i - 1][0], dp[i - 1][2] + abc[i - 1][0]) +    dp[i][1] = max(dp[i - 1][0] + abc[i - 1][1], dp[i - 1][2] + abc[i - 1][1]) +    dp[i][2] = max(dp[i - 1][0] + abc[i - 1][2], dp[i - 1][1] + abc[i - 1][2]) +print((max(dp[n])))