@staticmethod
def c():
    b = ([0] * 6)
    for i in range(2):
        (*row,) = map(int, sys.stdin.readline().split())
        for j in range(3):
            b[((i * 3) + j)] = row[j]
    c = ([0] * 8)
    for i in range(3):
        (*row,) = map(int, sys.stdin.readline().split())
        for j in range(2):
            c[((i * 3) + j)] = row[j]
    tot = (sum(b) + sum(c))

    @lru_cache(maxsize=None)
    def f(s=tuple((0 for _ in range(9)))):
        if all(s):
            res = 0
            for i in range(6):
                res += ((s[i] == s[(i + 3)]) * b[i])
            for i in range(8):
                res += ((s[i] == s[(i + 1)]) * c[i])
            return res
        cand = [i for i in range(9) if (not s[i])]
        flg = (len(cand) & 1)
        s = list(s)
        res = []
        for i in cand:
            s[i] = ((flg ^ 1) + 1)
            res.append(f(tuple(s)))
            s[i] = 0
        return sorted(res, reverse=flg)[0]
    a = f()
    b = (tot - a)
    print(a)
    print(b)
@staticmethod
def c():
    b = ([0] * 6)
    for i in range(2):
        (*row,) = map(int, sys.stdin.readline().split())
        for j in range(3):
            b[((i * 3) + j)] = row[j]
    c = ([0] * 8)
    for i in range(3):
        (*row,) = map(int, sys.stdin.readline().split())
        for j in range(2):
            c[((i * 3) + j)] = row[j]
    tot = (sum(b) + sum(c))

    @lru_cache(maxsize=None)
    def f(s=tuple((0 for _ in range(9)))):
        if all(s):
            res = 0
            for i in range(6):
                res += ((s[i] == s[(i + 3)]) * b[i])
            for i in range(8):
                res += ((s[i] == s[(i + 1)]) * c[i])
            return res
        cand = [i for i in range(9) if (not s[i])]
        flg = (len(cand) & 1)
        s = list(s)
        res = []
        for i in cand:
            s[i] = ((flg ^ 1) + 1)
            res.append(f(tuple(s)))
            s[i] = 0
        return sorted(res, reverse=flg)[0]
    a = f()
    b = (tot - a)
    print(a)
    print(b)