N = int(eval(input()))

dpa = [0] * N

dpb = [0] * N

dpc = [0] * N



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

dpa[0] = a

dpb[0] = b

dpc[0] = c

for i in range(1, N):

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

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

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

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



print((max(dpa[N-1], dpb[N-1], dpc[N-1])))
N = int(eval(input()))

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



# dp

dp_a = [0 for _ in range(N)]

dp_b, dp_c = dp_a.copy(), dp_a.copy()

dp_a[0] = abc[0][0]

dp_b[0] = abc[0][1]

dp_c[0] = abc[0][2]



for i in range(N - 1):

    dp_a[i + 1] = max(dp_b[i], dp_c[i]) + abc[i + 1][0]

    dp_b[i + 1] = max(dp_a[i], dp_c[i]) + abc[i + 1][1]

    dp_c[i + 1] = max(dp_a[i], dp_b[i]) + abc[i + 1][2]

print((max(dp_a[-1], dp_b[-1], dp_c[-1])))
N = int(eval(input()))
dpa = [0] * N
dpb = [0] * N
dpc = [0] * N
a, b, c = list(map(int, input().split()))
dpa[0] = a
dpb[0] = b
dpc[0] = c
for i in range(1, N):
    a, b, c = list(map(int, input().split()))
    dpa[i] = max(dpb[i - 1] + a, dpc[i - 1] + a)
    dpb[i] = max(dpa[i - 1] + b, dpc[i - 1] + b)
    dpc[i] = max(dpa[i - 1] + c, dpb[i - 1] + c)
print((max(dpa[N - 1], dpb[N - 1], dpc[N - 1])))

N = int(eval(input()))
abc = [list(map(int, input().split())) for _ in range(N)]
# dp
dp_a = [0 for _ in range(N)]
dp_b, dp_c = dp_a.copy(), dp_a.copy()
dp_a[0] = abc[0][0]
dp_b[0] = abc[0][1]
dp_c[0] = abc[0][2]
for i in range(N - 1):
    dp_a[i + 1] = max(dp_b[i], dp_c[i]) + abc[i + 1][0]
    dp_b[i + 1] = max(dp_a[i], dp_c[i]) + abc[i + 1][1]
    dp_c[i + 1] = max(dp_a[i], dp_b[i]) + abc[i + 1][2]
print((max(dp_a[-1], dp_b[-1], dp_c[-1])))

-dpa = [0] * N -dpb = [0] * N -dpc = [0] * N -a, b, c = list(map(int, input().split())) -dpa[0] = a -dpb[0] = b -dpc[0] = c -for i in range(1, N): -    a, b, c = list(map(int, input().split())) -    dpa[i] = max(dpb[i - 1] + a, dpc[i - 1] + a) -    dpb[i] = max(dpa[i - 1] + b, dpc[i - 1] + b) -    dpc[i] = max(dpa[i - 1] + c, dpb[i - 1] + c) -print((max(dpa[N - 1], dpb[N - 1], dpc[N - 1]))) +abc = [list(map(int, input().split())) for _ in range(N)] +# dp +dp_a = [0 for _ in range(N)] +dp_b, dp_c = dp_a.copy(), dp_a.copy() +dp_a[0] = abc[0][0] +dp_b[0] = abc[0][1] +dp_c[0] = abc[0][2] +for i in range(N - 1): +    dp_a[i + 1] = max(dp_b[i], dp_c[i]) + abc[i + 1][0] +    dp_b[i + 1] = max(dp_a[i], dp_c[i]) + abc[i + 1][1] +    dp_c[i + 1] = max(dp_a[i], dp_b[i]) + abc[i + 1][2] +print((max(dp_a[-1], dp_b[-1], dp_c[-1])))