import numpy as np


class Person:
    def __init__(self, list_score_my, list_score_other, list_eatable):
        self.list_score_my = list_score_my
        self.list_score_other = list_score_other
        self.list_eatable = list_eatable
        self.eatable = True
        self.score_sum = 0

    # other
    def get_score_max_other(self):
        return np.max(self.list_score_other)

    def get_score_max_other_eatable(self):
        return np.max(self.list_score_other * self.list_eatable)

    def get_index_of_score_max_other_eatable(self):
        return np.where(self.list_score_other == self.get_score_max_other_eatable())

    def is_other_has_same_max_score(self):
        flag = 0
        score_other_max = np.max(self.list_score_other)
        for i in self.list_score_other:
            if(self.list_score_other[i] == self.score_other_max):
                flag += 1

        if(flag > 1):
            return True
        else:
            return False

    # my
    def get_score_max_my(self):
        return np.max(self.list_score_my)

    def get_score_max_my_eatable(self):
        return np.max(self.list_score_my * self.list_eatable)

    def get_index_of_score_max_my_eatable(self):
        return np.where(self.list_score_my == self.get_score_max_my_eatable())

    def is_i_have_same_max_score(self):
        flag = 0
        self.score_my_max = np.max(self.list_score_my)
        for i in range(len(self.list_score_my)):
            if(self.list_score_my[i] == self.score_my_max):
                flag += 1
        if(flag > 1):
            return True
        else:
            return False

    def eat(self, index):
        self.list_eatable[index] = False
        self.score_sum += self.list_score_my[index]

    def print_score(self):
        print(self.list_score_my)


def get_data(ryouri_goukei_num):
    list_score_a = np.empty(ryouri_goukei_num)
    list_score_b = np.empty(ryouri_goukei_num)
    list_ryouri_is_eatable = np.empty(ryouri_goukei_num)

    for i in range(ryouri_goukei_num):
        inputData = input()
        splitData = inputData.split()
        a_data = int(splitData[0])
        b_data = int(splitData[1])
        list_score_a[i] = a_data
        list_score_b[i] = b_data
        list_ryouri_is_eatable[i] = True

    return list_score_a, list_score_b, list_ryouri_is_eatable


def main():
    ryouri_goukei_num = int(input())
    list_score_a, list_score_b, list_ryouri_is_eatable = get_data(
        ryouri_goukei_num)

    takahashi = Person(list_score_a, list_score_b, list_ryouri_is_eatable)
    aoki = Person(list_score_b, list_score_a, list_ryouri_is_eatable)

    takahashi.print_score()
    aoki.print_score()

    for i in range(ryouri_goukei_num):
        if(takahashi.eatable):
            if(takahashi.is_i_have_same_max_score()):
                takahashi.eat(takahashi.get_index_of_score_max_other_eatable())
            else:
                takahashi.eat(takahashi.get_index_of_score_max_my_eatable())

            takahashi.eatable = False
            aoki.eatable = True
            list_ryouri_is_eatable = takahashi.eatable
            continue

        if(aoki.eatable):
            if(aoki.is_i_have_same_max_score()):
                aoki.eat(aoki.get_index_of_score_max_other_eatable())
            else:
                aoki.eat(aoki.get_index_of_score_max_my_eatable())

            takahashi.eatable = True
            aoki.eatable = False
            list_ryouri_is_eatable = aoki.eatable
            continue

    print(int(takahashi.score_sum - aoki.score_sum))


main()


### FIXED CODE ###

inputDataStr = input()
splitData = list(map(int, inputDataStr.split()))
maxData = 0
minData = 0
allNinzuu = splitData[0]

if(splitData[1] > splitData[2]):
	maxData = splitData[1]
	minData = splitData[2]
else:
	maxData = splitData[2]
	minData = splitData[1]

if(allNinzuu > (splitData[1] + splitData[2])):
	minRyouhou = 0
else:
	minRyouhou =(splitData[1] + splitData[2]) - allNinzuu

print(minData, end=" ")
print(minRyouhou)