n=int(eval(input()))

l=[list(map(int,input().split())) for i in range(n)]

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



for i in range(n):

    #j==kの場合を除く

    for j in range(3):

        for k in range(3):

            

            if j!=k:

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

                

print((max(dp[-1])))
#DP-C



n=int(eval(input()))

l=[list(map(int,input().split())) for i in range(n)]



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

dp[0]=l[0]

#print(dp)



for i in range(1,n):

    for j in range(3):

        for k in range(3):

            #同じ活動の場合を除く

            if j!=k:

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

print((max(dp[-1])))
n = int(eval(input()))
l = [list(map(int, input().split())) for i in range(n)]
dp = [[0, 0, 0] for i in range(n + 1)]
for i in range(n):
    # j==kの場合を除く
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + l[i][j])
print((max(dp[-1])))

# DP-C
n = int(eval(input()))
l = [list(map(int, input().split())) for i in range(n)]
dp = [[0] * 3 for i in range(n)]
dp[0] = l[0]
# print(dp)
for i in range(1, n):
    for j in range(3):
        for k in range(3):
            # 同じ活動の場合を除く
            if j != k:
                dp[i][j] = max(dp[i - 1][k] + l[i][j], dp[i][j])
print((max(dp[-1])))

+# DP-C -dp = [[0, 0, 0] for i in range(n + 1)] -for i in range(n): -    # j==kの場合を除く +dp = [[0] * 3 for i in range(n)] +dp[0] = l[0] +# print(dp) +for i in range(1, n): +            # 同じ活動の場合を除く -                dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + l[i][j]) +                dp[i][j] = max(dp[i - 1][k] + l[i][j], dp[i][j])