N=int(eval(input()))



p=list(map(int,input().split()))



for i in range(1,N):

    add=list(map(int,input().split()))

    temp=[[] for j in range(3)]

    for j in range(3):

        pnt=p[j]

        for k in range(3):

            if j==k:continue

            else:

                temp[k].append(pnt+add[k])

    for j in range(3):

        p[j]=max(temp[j])

print((max(p)))
N=int(eval(input()))



p=list(map(int,input().split()))



for i in range(1,N):

    add=list(map(int,input().split()))

    p0=p[0]

    p1=p[1]

    p2=p[2]

    p[0]=max(add[0]+p1,add[0]+p2)

    p[1]=max(add[1]+p2,add[1]+p0)

    p[2]=max(add[2]+p0,add[2]+p1)



print((max(p)))



N = int(eval(input()))
p = list(map(int, input().split()))
for i in range(1, N):
    add = list(map(int, input().split()))
    temp = [[] for j in range(3)]
    for j in range(3):
        pnt = p[j]
        for k in range(3):
            if j == k:
                continue
            else:
                temp[k].append(pnt + add[k])
    for j in range(3):
        p[j] = max(temp[j])
print((max(p)))

N = int(eval(input()))
p = list(map(int, input().split()))
for i in range(1, N):
    add = list(map(int, input().split()))
    p0 = p[0]
    p1 = p[1]
    p2 = p[2]
    p[0] = max(add[0] + p1, add[0] + p2)
    p[1] = max(add[1] + p2, add[1] + p0)
    p[2] = max(add[2] + p0, add[2] + p1)
print((max(p)))

-    temp = [[] for j in range(3)] -    for j in range(3): -        pnt = p[j] -        for k in range(3): -            if j == k: -                continue -            else: -                temp[k].append(pnt + add[k]) -    for j in range(3): -        p[j] = max(temp[j]) +    p0 = p[0] +    p1 = p[1] +    p2 = p[2] +    p[0] = max(add[0] + p1, add[0] + p2) +    p[1] = max(add[1] + p2, add[1] + p0) +    p[2] = max(add[2] + p0, add[2] + p1)