ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

2078. Bowling game

Time limit: 2.0 second
Memory limit: 256 MB
In all asocial teams members ignore each other uniformly, each tight-knit team builds up team spirit their own way. Olya, Egor and Oleg, for example, go play bowling. This story is about how they once decided to take their coach Denis with them for the first time.
Denis is not used to close-knit teams and primitive fun, so he was not in favor of rolling balls. So when it came out that the device counting points near the lane was out of service, he willingly volunteered to perform the counting on a sheet of paper.
"What can be easier?", he thought, "One just needs to write down how many pins the player knocks down in each round. I can think out a couple of problems for the next training session simultaneously".
He has never been so wrong! At the end of the game it appeared that the scoring rules in bowling are not nearly just summing up knocked down pins, moreover, it came out that points cannot be restored from the number of knocked down pins. Oleg, Olya and Egor started to explain the rules of the game talking over each other: strikes, spares, extra roll in the last round... Denis nodded and thought: "Well, a decent problem we have here". He suggested the team calculating minimum and maximum points that can be scored by a player. It’s needless to say that Egor, Oleg and Olya completed this task easily. Now it’s your turn.
Here are the scoring rules in bowling.
  1. The game includes 10 frames (rounds), in each frame one can earn up to 30 points.
  2. In each frame, excluding the last one, the aim is to knock down 10 pins with two rolls. If all pins are knocked down with the first roll, the second roll is omitted.
  3. In the last frame one must initially knock down 10 pins with two rolls as well. If the player succeeds, (s)he gets an extra (third) roll. All available rolls must be used, that is, if all pins have been knocked down and there are rolls left, new 10 pins are put. These 10 pins, if knocked down, do not give extra rolls.
  4. Each knocked down pin gives one point.
  5. If a strike is made (all pins knocked down with one roll) in each frame excluding the last one, the player receives one extra point per each pin knocked down in two subsequent rolls when scoring that frame.
  6. If a spare is made (all pins knocked down with two rolls) in each frame excluding the last one, the player receives one extra point per each pin knocked down in one subsequent roll when scoring that frame.

Input

A single line contains 10 numbers separated by space — number of pins knocked down by the player in each of 10 frames. The first nine can take values from 0 to 10, the last one — from 0 to 30.

Output

Output minimum and maximum points a player could earn based on the game described in the input, separated by space.

Samples

inputoutput
10 2 4 8 3 8 1 9 8 7
60 62
2 4 6 8 10 10 8 6 4 2
60 86
Problem Author: Alexander Krasnoselskikh, prepared by Oleg Dolgorukov