import math,sys,bisect,heapq

from collections import defaultdict,Counter,deque

from itertools import groupby,accumulate

#sys.setrecursionlimit(200000000)

input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__

ilele = lambda: list(map(int,input().split()))

alele = lambda: list(map(int, input().split()))

def list2d(a, b, c): return [[c] * b for i in range(a)]

#def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]

MOD = 1000000000 + 7

def Y(c):  print((["NO","YES"][c]))

def y(c):  print((["no","yes"][c]))

def Yy(c):  print((["No","Yes"][c]))



x,y,z = 0,0,0

for _ in range(int(eval(input()))):

    a,b,c = ilele()

    if x == y == z == 0:

        x,y,z = a,b,c

    else:

        d = a + max(y,z)

        e = b + max(x,z)

        f = c + max(x,y)

        x,y,z = d,e,f

print((max(x,y,z)))

    
import math,sys,bisect,heapq

from collections import defaultdict,Counter,deque

from itertools import groupby,accumulate

#sys.setrecursionlimit(200000000)

input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__

ilele = lambda: list(map(int,input().split()))

alele = lambda: list(map(int, input().split()))

def list2d(a, b, c): return [[c] * b for i in range(a)]

#def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]

MOD = 1000000000 + 7

def Y(c):  print((["NO","YES"][c]))

def y(c):  print((["no","yes"][c]))

def Yy(c):  print((["No","Yes"][c]))



x,y,z = 0,0,0

for _ in range(int(eval(input()))):

    a,b,c = ilele()

    d = a + max(y,z)

    e = b + max(x,z)

    f = c + max(x,y)

    x,y,z = d,e,f

print((max(x,y,z)))

    
import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate

# sys.setrecursionlimit(200000000)
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: list(map(int, input().split()))
alele = lambda: list(map(int, input().split()))


def list2d(a, b, c):
    return [[c] * b for i in range(a)]


# def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7


def Y(c):
    print((["NO", "YES"][c]))


def y(c):
    print((["no", "yes"][c]))


def Yy(c):
    print((["No", "Yes"][c]))


x, y, z = 0, 0, 0
for _ in range(int(eval(input()))):
    a, b, c = ilele()
    if x == y == z == 0:
        x, y, z = a, b, c
    else:
        d = a + max(y, z)
        e = b + max(x, z)
        f = c + max(x, y)
        x, y, z = d, e, f
print((max(x, y, z)))

import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate

# sys.setrecursionlimit(200000000)
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: list(map(int, input().split()))
alele = lambda: list(map(int, input().split()))


def list2d(a, b, c):
    return [[c] * b for i in range(a)]


# def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7


def Y(c):
    print((["NO", "YES"][c]))


def y(c):
    print((["no", "yes"][c]))


def Yy(c):
    print((["No", "Yes"][c]))


x, y, z = 0, 0, 0
for _ in range(int(eval(input()))):
    a, b, c = ilele()
    d = a + max(y, z)
    e = b + max(x, z)
    f = c + max(x, y)
    x, y, z = d, e, f
print((max(x, y, z)))

-    if x == y == z == 0: -        x, y, z = a, b, c -    else: -        d = a + max(y, z) -        e = b + max(x, z) -        f = c + max(x, y) -        x, y, z = d, e, f +    d = a + max(y, z) +    e = b + max(x, z) +    f = c + max(x, y) +    x, y, z = d, e, f