def MAP(): return list(map(int,input().split()))

def INT(): return int(eval(input()))

def FLOAT(): return float(eval(input()))

MOD = 10**9+7



n = INT()

a = [MAP() for _ in range(n)]

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



for i in range(n):

    for j in range(3):

        for k in range(3):

            if j==k:

                continue

            dp[i+1][k] = max(dp[i+1][k],dp[i][j]+a[i][k])



print((max(dp[n])))
n = int(eval(input()))



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

a = []



for i in range(n):

    a.append(list(map(int,input().split())))



for i in range(n):

    for j in range(3):

        for k in range(3):

            if j==k:

                continue

            dp[i+1][j] = max(dp[i+1][j],dp[i][k] + a[i][j])



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

def MAP():
    return list(map(int, input().split()))


def INT():
    return int(eval(input()))


def FLOAT():
    return float(eval(input()))


MOD = 10**9 + 7
n = INT()
a = [MAP() for _ in range(n)]
dp = [[0, 0, 0] for _ in range(n + 1)]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k])
print((max(dp[n])))

n = int(eval(input()))
dp = [[0] * 3 for i in range(n + 1)]
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + a[i][j])
print((max(dp[n])))

-def MAP(): -    return list(map(int, input().split())) - - -def INT(): -    return int(eval(input())) - - -def FLOAT(): -    return float(eval(input())) - - -MOD = 10**9 + 7 -n = INT() -a = [MAP() for _ in range(n)] -dp = [[0, 0, 0] for _ in range(n + 1)] +n = int(eval(input())) +dp = [[0] * 3 for i in range(n + 1)] +a = [] +for i in range(n): +    a.append(list(map(int, input().split()))) -            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k]) +            dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + a[i][j])