n = int(eval(input()))

A = []

B = []

C = []

for i in range(n):

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

    A.append(a)

    B.append(b)

    C.append(c)

    

dp = [[0 for i in range(3)] for j in range(n)]



dp[0][0] = A[0]

dp[0][1] = B[0]

dp[0][2] = C[0]



for i in range(1,n):

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

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

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



print((max(dp[n-1][0],dp[n-1][1],dp[n-1][2])))
n = int(eval(input()))

A = []

B = []

C = []

for _ in range(n):

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

    A.append(a)

    B.append(b)

    C.append(c)

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

dp[0][0] = A[0]

dp[0][1] = B[0]

dp[0][2] = C[0]

for i in range(1,n):

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

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

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

print((max(dp[-1])))
n = int(eval(input()))
A = []
B = []
C = []
for i in range(n):
    a, b, c = list(map(int, input().split()))
    A.append(a)
    B.append(b)
    C.append(c)
dp = [[0 for i in range(3)] for j in range(n)]
dp[0][0] = A[0]
dp[0][1] = B[0]
dp[0][2] = C[0]
for i in range(1, n):
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i]
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + B[i]
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + C[i]
print((max(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2])))

n = int(eval(input()))
A = []
B = []
C = []
for _ in range(n):
    a, b, c = list(map(int, input().split()))
    A.append(a)
    B.append(b)
    C.append(c)
dp = [[0] * 3 for i in range(n)]
dp[0][0] = A[0]
dp[0][1] = B[0]
dp[0][2] = C[0]
for i in range(1, n):
    dp[i][0] = max(dp[i - 1][1] + A[i], dp[i - 1][2] + A[i])
    dp[i][1] = max(dp[i - 1][0] + B[i], dp[i - 1][2] + B[i])
    dp[i][2] = max(dp[i - 1][0] + C[i], dp[i - 1][1] + C[i])
print((max(dp[-1])))

-for i in range(n): +for _ in range(n): -dp = [[0 for i in range(3)] for j in range(n)] +dp = [[0] * 3 for i in range(n)] -    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i] -    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + B[i] -    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + C[i] -print((max(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]))) +    dp[i][0] = max(dp[i - 1][1] + A[i], dp[i - 1][2] + A[i]) +    dp[i][1] = max(dp[i - 1][0] + B[i], dp[i - 1][2] + B[i]) +    dp[i][2] = max(dp[i - 1][0] + C[i], dp[i - 1][1] + C[i]) +print((max(dp[-1])))