n = int(eval(input()))

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



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

dp[0] = l[0]



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][j], dp[i-1][k] + l[i][j])



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

abc  = [[], [], []]



abc = [list(map(int, input().split())) for _ in range(n)] # DB取得方法のみ違う, 分かればどっちでもok

#print(abc)



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

dp[0] = abc[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][j], dp[i-1][k] + abc[i][j]) # ここのDB指定方法に影響



print((max(dp[-1])))
n = int(eval(input()))
l = [list(map(int, input().split())) for _ in range(n)]
dp = [[0, 0, 0] for _ in range(n)]
dp[0] = l[0]
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][j], dp[i - 1][k] + l[i][j])
print((max(dp[-1])))

n = int(eval(input()))
abc = [[], [], []]
abc = [list(map(int, input().split())) for _ in range(n)]  # DB取得方法のみ違う, 分かればどっちでもok
# print(abc)
dp = [[0, 0, 0] for _ in range(n)]
dp[0] = abc[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][j], dp[i - 1][k] + abc[i][j])  # ここのDB指定方法に影響
print((max(dp[-1])))

-l = [list(map(int, input().split())) for _ in range(n)] +abc = [[], [], []] +abc = [list(map(int, input().split())) for _ in range(n)]  # DB取得方法のみ違う, 分かればどっちでもok +# print(abc) -dp[0] = l[0] +dp[0] = abc[0] +# print(dp) -                dp[i][j] = max(dp[i][j], dp[i - 1][k] + l[i][j]) +                dp[i][j] = max(dp[i][j], dp[i - 1][k] + abc[i][j])  # ここのDB指定方法に影響