N = int(eval(input()))



ABC = []

for _ in range(N):

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

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



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



for i, abc in enumerate(ABC):

  for k in range(3):

    if (i == 0):

      dp[i][k] = abc[k]

    else:

      max_dp_i = dp[i][k]

      for j in range(3):

        if (k == j):

          continue

        if (max_dp_i < (dp[i-1][j] + abc[k])):

          max_dp_i = (dp[i-1][j] + abc[k])

      

      dp[i][k] = max_dp_i



print((max(dp[-1])))
import sys

input = sys.stdin.readline



N = int(eval(input()))

ABC = []

for _ in range(N):

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

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



dp = [[0] * 3 for _ in range(N)]



for day, abc in enumerate(ABC):

  for t_act in range(3):

    if (day == 0):

      dp[day][t_act] = abc[t_act]

      continue

    t_max = dp[day][t_act] # 0

    for y_act in range(3):

      if(t_act == y_act):

        continue

      happy = dp[day - 1][y_act] + abc[t_act]

      if (t_max < happy):

        t_max = happy

    

    dp[day][t_act] = t_max



print((max(dp[N - 1])))

N = int(eval(input()))
ABC = []
for _ in range(N):
    a, b, c = list(map(int, input().split()))
    ABC.append((a, b, c))
dp = [[0] * 3 for i in range(N)]
for i, abc in enumerate(ABC):
    for k in range(3):
        if i == 0:
            dp[i][k] = abc[k]
        else:
            max_dp_i = dp[i][k]
            for j in range(3):
                if k == j:
                    continue
                if max_dp_i < (dp[i - 1][j] + abc[k]):
                    max_dp_i = dp[i - 1][j] + abc[k]
            dp[i][k] = max_dp_i
print((max(dp[-1])))

import sys

input = sys.stdin.readline
N = int(eval(input()))
ABC = []
for _ in range(N):
    a, b, c = list(map(int, input().split()))
    ABC.append((a, b, c))
dp = [[0] * 3 for _ in range(N)]
for day, abc in enumerate(ABC):
    for t_act in range(3):
        if day == 0:
            dp[day][t_act] = abc[t_act]
            continue
        t_max = dp[day][t_act]  # 0
        for y_act in range(3):
            if t_act == y_act:
                continue
            happy = dp[day - 1][y_act] + abc[t_act]
            if t_max < happy:
                t_max = happy
        dp[day][t_act] = t_max
print((max(dp[N - 1])))

+import sys + +input = sys.stdin.readline -dp = [[0] * 3 for i in range(N)] -for i, abc in enumerate(ABC): -    for k in range(3): -        if i == 0: -            dp[i][k] = abc[k] -        else: -            max_dp_i = dp[i][k] -            for j in range(3): -                if k == j: -                    continue -                if max_dp_i < (dp[i - 1][j] + abc[k]): -                    max_dp_i = dp[i - 1][j] + abc[k] -            dp[i][k] = max_dp_i -print((max(dp[-1]))) +dp = [[0] * 3 for _ in range(N)] +for day, abc in enumerate(ABC): +    for t_act in range(3): +        if day == 0: +            dp[day][t_act] = abc[t_act] +            continue +        t_max = dp[day][t_act]  # 0 +        for y_act in range(3): +            if t_act == y_act: +                continue +            happy = dp[day - 1][y_act] + abc[t_act] +            if t_max < happy: +                t_max = happy +        dp[day][t_act] = t_max +print((max(dp[N - 1])))