Yahtzee is a game played with 5 dice over 13 rounds. A score card has 13 categories. In each round the player chooses one category to score, and each category may be used exactly once in the whole game. In other words, you must assign the 13 rounds one-to-one to the 13 categories.
Each category is scored as follows:
For the last six categories (three of a kind through full house), a category is scored as 0 whenever its condition is not met.
The score of a game is the sum of all 13 category scores, plus a bonus of 35 points if the sum of the first six categories (ones through sixes) is 63 or more.
For each game, compute the maximum total score that can be achieved.
Each line of input contains 5 integers between 1 and 6, separated by spaces, giving the values of the five dice thrown in one round. Each game consists of 13 such lines, and the input may contain any number of games, one after another, until end of file.
For each game, print a single line containing the maximum total score (a single integer) that can be achieved for that game.