def LIST():

    return list(map(int, input().split()))

N = int(eval(input()))

arr = [LIST() for _ in range(N)]

dp = [[arr[0][0],arr[0][1],arr[0][2]],[0,0,0]]

l=1

p=0

for i in range(1, N):

    for j in range(3):

        for k in range(3):

            if j == k: continue

            a1=dp[p][j]

            a2=arr[i][k]

            a3=a1+a2

            dp[l][k] = max(dp[l][k], dp[p][j] + arr[i][k])

    l=l^1

    p=p^1

            

print((max([dp[p][j] for j in range(3)])))
N=int(eval(input()))

arr = [int(a) for a in input().split()]

dp = [[arr[0],arr[1],arr[2]],[0,0,0]]

l=1

p=0

for i in range(1, N):

    arr = list(map(int, input().split()))

    for j in range(3):

        for k in range(3):

            if j == k: continue

            dp[l][k] = max(dp[l][k], dp[p][j] + arr[k])

    l=l^1

    p=p^1

            

print((max([dp[p][j] for j in range(3)])))
def LIST():
    return list(map(int, input().split()))


N = int(eval(input()))
arr = [LIST() for _ in range(N)]
dp = [[arr[0][0], arr[0][1], arr[0][2]], [0, 0, 0]]
l = 1
p = 0
for i in range(1, N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            a1 = dp[p][j]
            a2 = arr[i][k]
            a3 = a1 + a2
            dp[l][k] = max(dp[l][k], dp[p][j] + arr[i][k])
    l = l ^ 1
    p = p ^ 1
print((max([dp[p][j] for j in range(3)])))

N = int(eval(input()))
arr = [int(a) for a in input().split()]
dp = [[arr[0], arr[1], arr[2]], [0, 0, 0]]
l = 1
p = 0
for i in range(1, N):
    arr = list(map(int, input().split()))
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[l][k] = max(dp[l][k], dp[p][j] + arr[k])
    l = l ^ 1
    p = p ^ 1
print((max([dp[p][j] for j in range(3)])))

-def LIST(): -    return list(map(int, input().split())) - - -arr = [LIST() for _ in range(N)] -dp = [[arr[0][0], arr[0][1], arr[0][2]], [0, 0, 0]] +arr = [int(a) for a in input().split()] +dp = [[arr[0], arr[1], arr[2]], [0, 0, 0]] +    arr = list(map(int, input().split())) -            a1 = dp[p][j] -            a2 = arr[i][k] -            a3 = a1 + a2 -            dp[l][k] = max(dp[l][k], dp[p][j] + arr[i][k]) +            dp[l][k] = max(dp[l][k], dp[p][j] + arr[k])