N = int(eval(input()))



abc = [list([int(x) for x in input().split()]) for _ in range(N)]



happy = [[0] * 3 for _ in range(N)]

for i in range(3):

	happy[0][i] = abc[0][i]



for i in range(1, N):

	for j in range(3):

		for k in range(3):

			if j != k and happy[i][j] < happy[i - 1][k]:

				happy[i][j] = happy[i - 1][k]

		happy[i][j] += abc[i][j]



print((max(happy[N - 1][0], happy[N - 1][1], happy[N - 1][2])))
N = int(eval(input()))



abc = [list([int(x) for x in input().split()]) for _ in range(N)]



happy = [[0] * 3 for _ in range(N)]

for i in range(3):

	happy[0][i] = abc[0][i]



for i in range(1, N):

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

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

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



print((max(happy[N - 1][0], happy[N - 1][1], happy[N - 1][2])))
N = int(eval(input()))
abc = [list([int(x) for x in input().split()]) for _ in range(N)]
happy = [[0] * 3 for _ in range(N)]
for i in range(3):
    happy[0][i] = abc[0][i]
for i in range(1, N):
    for j in range(3):
        for k in range(3):
            if j != k and happy[i][j] < happy[i - 1][k]:
                happy[i][j] = happy[i - 1][k]
        happy[i][j] += abc[i][j]
print((max(happy[N - 1][0], happy[N - 1][1], happy[N - 1][2])))

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

-    for j in range(3): -        for k in range(3): -            if j != k and happy[i][j] < happy[i - 1][k]: -                happy[i][j] = happy[i - 1][k] -        happy[i][j] += abc[i][j] +    happy[i][0] = max(happy[i - 1][1], happy[i - 1][2]) + abc[i][0] +    happy[i][1] = max(happy[i - 1][0], happy[i - 1][2]) + abc[i][1] +    happy[i][2] = max(happy[i - 1][0], happy[i - 1][1]) + abc[i][2]