n = int(eval(input()))

abc=[[0,0,0]]*n

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



for i in range(n):

  abc[i] = list(map(int,input().split()))

  

for i in range(3):

  dp[i][0] = abc[0][i]



for i in range(1,n):

  for j in range(3):    

    for k in range(3):

      if j==k:

        pass

      else:

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

        

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

abc=[[]]*n

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



for i in range(n):

  abc[i] = list(map(int,input().split()))



for i in range(3):

  dp[0][i] = abc[0][i]



for i in range(1,n):

  dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + abc[i][0]

  dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + abc[i][1]

  dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + abc[i][2]

          

print((max(dp[-1])))          
n = int(eval(input()))
abc = [[0, 0, 0]] * n
dp = [[0] * n for _ in range(3)]
for i in range(n):
    abc[i] = list(map(int, input().split()))
for i in range(3):
    dp[i][0] = abc[0][i]
for i in range(1, n):
    for j in range(3):
        for k in range(3):
            if j == k:
                pass
            else:
                dp[j][i] = max(dp[j][i], dp[k][i - 1] + abc[i][j])
print((max([row[-1] for row in dp])))

n = int(eval(input()))
abc = [[]] * n
dp = [[0] * 3 for _ in range(n)]
for i in range(n):
    abc[i] = list(map(int, input().split()))
for i in range(3):
    dp[0][i] = abc[0][i]
for i in range(1, n):
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + abc[i][0]
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + abc[i][1]
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + abc[i][2]
print((max(dp[-1])))

-abc = [[0, 0, 0]] * n -dp = [[0] * n for _ in range(3)] +abc = [[]] * n +dp = [[0] * 3 for _ in range(n)] -    dp[i][0] = abc[0][i] +    dp[0][i] = abc[0][i] -    for j in range(3): -        for k in range(3): -            if j == k: -                pass -            else: -                dp[j][i] = max(dp[j][i], dp[k][i - 1] + abc[i][j]) -print((max([row[-1] for row in dp]))) +    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + abc[i][0] +    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + abc[i][1] +    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + abc[i][2] +print((max(dp[-1])))