import numpy as np



N = int(eval(input()))

# a = np.array([int(i) for i in input().split()])

a = np.array([input().split() for i in range(N)], dtype=int)



dp = np.zeros((N, 3), dtype=int)

dp[0] = a[0]



for i in range(1, N):

    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] + a[i][k])



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

import numpy as np



N = int(eval(input()))

a = np.array([input().split() for i in range(N)], dtype=int)



dp = np.zeros((N, 3), dtype=int)

dp[0] = a[0]



for i in range(1, N):

    dp[i] = [

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

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

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

    ]



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

import numpy as np

N = int(eval(input()))
# a = np.array([int(i) for i in input().split()])
a = np.array([input().split() for i in range(N)], dtype=int)
dp = np.zeros((N, 3), dtype=int)
dp[0] = a[0]
for i in range(1, N):
    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] + a[i][k])
print((np.max(dp[-1])))

import numpy as np

N = int(eval(input()))
a = np.array([input().split() for i in range(N)], dtype=int)
dp = np.zeros((N, 3), dtype=int)
dp[0] = a[0]
for i in range(1, N):
    dp[i] = [
        a[i][0] + max(dp[i - 1][1], dp[i - 1][2]),
        a[i][1] + max(dp[i - 1][2], dp[i - 1][0]),
        a[i][2] + max(dp[i - 1][0], dp[i - 1][1]),
    ]
print((np.max(dp[-1])))

-# a = np.array([int(i) for i in input().split()]) -    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] + a[i][k]) +    dp[i] = [ +        a[i][0] + max(dp[i - 1][1], dp[i - 1][2]), +        a[i][1] + max(dp[i - 1][2], dp[i - 1][0]), +        a[i][2] + max(dp[i - 1][0], dp[i - 1][1]), +    ]