https://www.acmicpc.net/problem/2096
import sys
read = sys.stdin.readline
n = int(read())
board = [list(map(int, read().split())) for _ in range(n)]
dp_max = [board[0], [0,0,0]]
dp_min = [board[0], [0,0,0]]
for y in range(1, n):
dp_max[1][0] = max(dp_max[0][0], dp_max[0][1]) + board[y][0]
dp_max[1][1] = max(dp_max[0]) + board[y][1]
dp_max[1][2] = max(dp_max[0][1], dp_max[0][2]) + board[y][2]
dp_max[0] = dp_max[1][:]
dp_min[1][0] = min(dp_min[0][0], dp_min[0][1]) + board[y][0]
dp_min[1][1] = min(dp_min[0]) + board[y][1]
dp_min[1][2] = min(dp_min[0][1], dp_min[0][2]) + board[y][2]
dp_min[0] = dp_min[1][:]
print(max(dp_max[0]), min(dp_min[0]))