n=int(eval(input()))

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



for i in range(n):

    a,b,c=list(map(int,input().split()))

    if i==0:

        x[i][0]=a 

        x[i][1]=b

        x[i][2]=c 

    else:

        x[i][0]=max(x[i-1][1],x[i-1][2])+a

        x[i][1]=max(x[i-1][0],x[i-1][2])+b

        x[i][2]=max(x[i-1][0],x[i-1][1])+c

    

print((max(x[n-1])))
#dp[x][i]=x日目に、場所iへ、行くときの幸福度の総和の最大値 連日iに行くことはできない縛りがある

#直前＝昨日にいった場所をjとすると、j!=iで表せる 

n=int(eval(input()))



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

happy=[]

for i in range(n):

    a,b,c=list(map(int,input().split()))

    happy.append((a,b,c))

for i in range(3):

    dp[0][i]=happy[0][i]

for i in range(1,n):

    for t_place in range(3):

        for y_place in range(3):

            if t_place==y_place:

                continue

            dp[i][t_place]=max(dp[i][t_place],dp[i-1][y_place]+happy[i][t_place])#昨日来た場所と今日行く場所の幸福度の和

print((max(dp[n-1])))
n = int(eval(input()))
x = [[0] * 3 for i in range(n)]
for i in range(n):
    a, b, c = list(map(int, input().split()))
    if i == 0:
        x[i][0] = a
        x[i][1] = b
        x[i][2] = c
    else:
        x[i][0] = max(x[i - 1][1], x[i - 1][2]) + a
        x[i][1] = max(x[i - 1][0], x[i - 1][2]) + b
        x[i][2] = max(x[i - 1][0], x[i - 1][1]) + c
print((max(x[n - 1])))

# dp[x][i]=x日目に、場所iへ、行くときの幸福度の総和の最大値 連日iに行くことはできない縛りがある
# 直前＝昨日にいった場所をjとすると、j!=iで表せる
n = int(eval(input()))
dp = [[0 for i in range(3)] for j in range(n)]
happy = []
for i in range(n):
    a, b, c = list(map(int, input().split()))
    happy.append((a, b, c))
for i in range(3):
    dp[0][i] = happy[0][i]
for i in range(1, n):
    for t_place in range(3):
        for y_place in range(3):
            if t_place == y_place:
                continue
            dp[i][t_place] = max(
                dp[i][t_place], dp[i - 1][y_place] + happy[i][t_place]
            )  # 昨日来た場所と今日行く場所の幸福度の和
print((max(dp[n - 1])))

+# dp[x][i]=x日目に、場所iへ、行くときの幸福度の総和の最大値 連日iに行くことはできない縛りがある +# 直前＝昨日にいった場所をjとすると、j!=iで表せる -x = [[0] * 3 for i in range(n)] +dp = [[0 for i in range(3)] for j in range(n)] +happy = [] -    if i == 0: -        x[i][0] = a -        x[i][1] = b -        x[i][2] = c -    else: -        x[i][0] = max(x[i - 1][1], x[i - 1][2]) + a -        x[i][1] = max(x[i - 1][0], x[i - 1][2]) + b -        x[i][2] = max(x[i - 1][0], x[i - 1][1]) + c -print((max(x[n - 1]))) +    happy.append((a, b, c)) +for i in range(3): +    dp[0][i] = happy[0][i] +for i in range(1, n): +    for t_place in range(3): +        for y_place in range(3): +            if t_place == y_place: +                continue +            dp[i][t_place] = max( +                dp[i][t_place], dp[i - 1][y_place] + happy[i][t_place] +            )  # 昨日来た場所と今日行く場所の幸福度の和 +print((max(dp[n - 1])))