n,*l=list(map(int,open(0).read().split()))

a=l[::3]

b=l[1::3]

c=l[2::3]

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

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

A,B,C=dp[0]

for i in range(1,n):

	dp[i]=[ a[i]+max(B,C) , b[i]+max(C,A) , c[i]+max(A,B) ]

	A,B,C=dp[i]

print((max(dp[-1])))
n,*l=list(map(int,open(0).read().split()))

a=l[::3];b=l[1::3];c=l[2::3]

A,B,C=a[0],b[0],c[0]

M=max

for i in range(1,n):

	A,B,C=a[i]+M(B,C),b[i]+M(C,A),c[i]+M(A,B)

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

n, *l = list(map(int, open(0).read().split()))
a = l[::3]
b = l[1::3]
c = l[2::3]
A, B, C = a[0], b[0], c[0]
M = max
for i in range(1, n):
    A, B, C = a[i] + M(B, C), b[i] + M(C, A), c[i] + M(A, B)
print((M(A, B, C)))

-dp = [[0] * 3 for _ in range(n)] -dp[0] = [a[0], b[0], c[0]] -A, B, C = dp[0] +A, B, C = a[0], b[0], c[0] +M = max -    dp[i] = [a[i] + max(B, C), b[i] + max(C, A), c[i] + max(A, B)] -    A, B, C = dp[i] -print((max(dp[-1]))) +    A, B, C = a[i] + M(B, C), b[i] + M(C, A), c[i] + M(A, B) +print((M(A, B, C)))