The ACM team of BNU is recruiting new members!
After multiple rounds of selection, all candidates have successfully joined the team, except wzj and xyz, whose final spots are still pending.
You decide to team up with them for an ACM contest to evaluate their coding skills. The three of you share one computer during the contest. The problems are fairly easy, so you solve all of them effortlessly and assign a score to each problem. Then you let wzj and xyz take turns to write code for the problems. wzj moves first, and xyz moves second. Both of them hope to win your recognition, so they try to maximize their own total scores to show their ability.
There are $$$n$$$ problems in total, and each problem belongs to one of the following two types:
wzj and xyz take turns to make moves, with wzj moving first. On each turn, the current player must select and complete one problem from all currently available problems, and gain the score of that problem.
Definition of available problems:
The game ends after all problems are completed.
Both players aim to maximize their own total score. Given that both of them adopt optimal strategies, please calculate the final scores of wzj and xyz.
The first line contains an integer $$$n$$$ $$$(1 \le n \le 2 \times 10^5)$$$, denoting the number of problems (each problem is either single-part or two-part).
The following $$$n$$$ lines each describe one problem:
Output two integers separated by a single space on one line, which are the total scores of wzj and xyz under optimal strategies.
32 1 1002 6 51 3
109 6