C. Fox and Card Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFox Ciel is playing a card game with her friend Fox Jiro. There are n piles of cards on the table. And there is a positive integer on each card.The players take turns and Ciel takes the first turn. In Ciel's turn she takes a card from the top of any non-empty pile, and in Jiro's turn he takes a card from the bottom of any non-empty pile. Each player wants to maximize the total sum of the cards he took. The game ends when all piles become empty.Suppose Ciel and Jiro play optimally, what is the score of the game?InputThe first line contain an integer n (1 ≤ n ≤ 100). Each of the next n lines contains a description of the pile: the first integer in the line is si (1 ≤ si ≤ 100) — the number of cards in the i-th pile; then follow si positive integers c1, c2, ..., ck, ..., csi (1 ≤ ck ≤ 1000) — the sequence of the numbers on the cards listed from top of the current pile to bottom of the pile.OutputPrint two integers: the sum of Ciel's cards and the sum of Jiro's cards if they play optimally.ExamplesInput21 1002 1 10Output101 10Input19 2 8 6 5 9 4 7 1 3Output30 15Input33 1 3 23 5 4 62 8 7Output18 18Input33 1000 1000 10006 1000 1000 1000 1000 1000 10005 1000 1000 1000 1000 1000Output7000 7000NoteIn the first example, Ciel will take the cards with number 100 and 1, Jiro will take the card with number 10.In the second example, Ciel will take cards with numbers 2, 8, 6, 5, 9 and Jiro will take cards with numbers 4, 7, 1, 3.
Input21 1002 1 10
Output101 10
['games', 'greedy', 'sortings', '*2000']