Back
Close

Scratchcard

Statement

 Goal

Given a scratchcard, determine the winning amount (if anything) the scratchcard yields. If three identical amounts is found, the winning is a one time payment of that amount. But if three symbols is found a special price is given: every month a specific amount is payed to the winner for several years in the future.

There is also one special bonus field on the scratchcard and the value of this field can be an amount, a symbol or a multiplier specified like x2. An amount or a counts just as usual, but the bonus field is the only one which can be a multiplier. In this case the winning amount will be multiplied as specified.
Input
First three (3) lines: Each line specifies three integers/ separated by a space
Fourth line: Specifies the bonus field; either an integer multiplier xN, an integer specifying an amount or a symbol
Output
The output is one line which can be one of the following:
- an integer N specifying the exact amount that the scratchcard yields (might be 0)
- the word Monthly in case of three symbols
Constraints
Any amount A found on the scratchcard will comply with 1 ≤ A ≤ 100000
A multiplier is always positive and non-zero
A scratchcard with a monthly winning will never have a multiplier other than x1
On a scratchcard there will never be more than one value that is repeated three times
Example
Input
10 50 100
25 50 100
100 25 10
x3
Output
300

Game modes
Fastest, Shortest

Test cases
Test 1 Test
Input
10 50 100 25 50 100 100 25 10 x3
Output
300

Validator 1 Validator
Input
10 50 200 25 5000 200 5000 25 10 200
Output
200

Test 2 Test
Input
10 5000 100 25 50 100 100 25 10 x10
Output
1000

Validator 2 Validator
Input
1000 5000 500 500 50 100000 10000 25 200 x100
Output
0

Test 3 Test
Input
10 25 500 25 ♣ 100 100 25 50 x5
Output
125

Validator 3 Validator
Input
50 50000 ♣ 5000 ♣ 100 10000 25 10000 ♣
Output
Monthly

Test 4 Test
Input
100 5000 ♣ ♣ 1000 25 100 25 ♣ x1
Output
Monthly

Validator 4 Validator
Input
10000 5000 ♣ 5000 10000 25 100 25 ♣ 10000
Output
10000

Solution language

Solution

Stub generator input