n=int(eval(input()))

a=[0]*(n)

b=[0]*(n)

c=[0]*(n)

for _ in range(n):a[_],b[_],c[_]=list(map(int,input().split()))



INF=float("inf")

dpa=[-INF]*n

dpb=[-INF]*n

dpc=[-INF]*n

dpa[0]=a[0]

dpb[0]=b[0]

dpc[0]=c[0]



for i in range(1,n):

    dpa[i]=a[i]+max(dpb[i-1],dpc[i-1])

    dpb[i]=b[i]+max(dpc[i-1],dpa[i-1])

    dpc[i]=c[i]+max(dpa[i-1],dpb[i-1])

    

print((max(dpa[-1],dpb[-1],dpc[-1])))

    





n=int(eval(input()))

a=[0]*(n)

b=[0]*(n)

c=[0]*(n)

for i in range(n):

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



INF=float("inf")

dpa=[-INF]*n

dpb=[-INF]*n

dpc=[-INF]*n

dpa[0]=a[0]

dpb[0]=b[0]

dpc[0]=c[0]



for i in range(1,n):

    dpa[i]=a[i]+max(dpb[i-1],dpc[i-1])

    dpb[i]=b[i]+max(dpc[i-1],dpa[i-1])

    dpc[i]=c[i]+max(dpa[i-1],dpb[i-1])

    

print((max(dpa[-1],dpb[-1],dpc[-1])))

    





n = int(eval(input()))
a = [0] * (n)
b = [0] * (n)
c = [0] * (n)
for _ in range(n):
    a[_], b[_], c[_] = list(map(int, input().split()))
INF = float("inf")
dpa = [-INF] * n
dpb = [-INF] * n
dpc = [-INF] * n
dpa[0] = a[0]
dpb[0] = b[0]
dpc[0] = c[0]
for i in range(1, n):
    dpa[i] = a[i] + max(dpb[i - 1], dpc[i - 1])
    dpb[i] = b[i] + max(dpc[i - 1], dpa[i - 1])
    dpc[i] = c[i] + max(dpa[i - 1], dpb[i - 1])
print((max(dpa[-1], dpb[-1], dpc[-1])))

n = int(eval(input()))
a = [0] * (n)
b = [0] * (n)
c = [0] * (n)
for i in range(n):
    a[i], b[i], c[i] = list(map(int, input().split()))
INF = float("inf")
dpa = [-INF] * n
dpb = [-INF] * n
dpc = [-INF] * n
dpa[0] = a[0]
dpb[0] = b[0]
dpc[0] = c[0]
for i in range(1, n):
    dpa[i] = a[i] + max(dpb[i - 1], dpc[i - 1])
    dpb[i] = b[i] + max(dpc[i - 1], dpa[i - 1])
    dpc[i] = c[i] + max(dpa[i - 1], dpb[i - 1])
print((max(dpa[-1], dpb[-1], dpc[-1])))

-for _ in range(n): -    a[_], b[_], c[_] = list(map(int, input().split())) +for i in range(n): +    a[i], b[i], c[i] = list(map(int, input().split()))