N = int(eval(input()))

ABC = (list(map(int, input().split())) for _ in range(N))



DP = [[0, 0, 0] for _ in range(N)]



for i, abc in enumerate(ABC):

  if i == 0:

    for j in range(3):

      DP[i][j] = abc[j]

  else:

    for j in range(3):

      DP[i][j] = max(DP[i-1][k] + abc[j] for k in range(3) if j != k)



print((max(DP[N-1])))
N, = list(map(int, input().split()))



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



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



for i in range(N):

  for j in range(3):

    if i - 1 < 0:

      dp[i][j] += ABC[i][j]

    else:

      x = (j + 1) % 3

      y = (j + 2) % 3

      dp[i][j] = max(dp[i-1][x], dp[i-1][y]) + ABC[i][j]



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

N = int(eval(input()))
ABC = (list(map(int, input().split())) for _ in range(N))
DP = [[0, 0, 0] for _ in range(N)]
for i, abc in enumerate(ABC):
    if i == 0:
        for j in range(3):
            DP[i][j] = abc[j]
    else:
        for j in range(3):
            DP[i][j] = max(DP[i - 1][k] + abc[j] for k in range(3) if j != k)
print((max(DP[N - 1])))

(N,) = list(map(int, input().split()))
ABC = [list(map(int, input().split())) for i in range(N)]
dp = [[0] * 3 for i in range(N)]
for i in range(N):
    for j in range(3):
        if i - 1 < 0:
            dp[i][j] += ABC[i][j]
        else:
            x = (j + 1) % 3
            y = (j + 2) % 3
            dp[i][j] = max(dp[i - 1][x], dp[i - 1][y]) + ABC[i][j]
print((max(dp[N - 1])))

-N = int(eval(input())) -ABC = (list(map(int, input().split())) for _ in range(N)) -DP = [[0, 0, 0] for _ in range(N)] -for i, abc in enumerate(ABC): -    if i == 0: -        for j in range(3): -            DP[i][j] = abc[j] -    else: -        for j in range(3): -            DP[i][j] = max(DP[i - 1][k] + abc[j] for k in range(3) if j != k) -print((max(DP[N - 1]))) +(N,) = list(map(int, input().split())) +ABC = [list(map(int, input().split())) for i in range(N)] +dp = [[0] * 3 for i in range(N)] +for i in range(N): +    for j in range(3): +        if i - 1 < 0: +            dp[i][j] += ABC[i][j] +        else: +            x = (j + 1) % 3 +            y = (j + 2) % 3 +            dp[i][j] = max(dp[i - 1][x], dp[i - 1][y]) + ABC[i][j] +print((max(dp[N - 1])))