Girls Invitational '18 J2 - Munara’s Magnificent Math Machine

View as PDF

Submit solution

Points: 3
Time limit: 1.5s
Memory limit: 64M

Problem type

Munara has created a Magnificent Math Machine. Her machine will take any integer, \(I\ (0 \le I \le 100)\), and perform 3 operations on it: addition, multiplication, and subtraction.

Each time she feeds a number, \(N\ (1 \le N \le 100)\), through the machine, Munara must indicate which numbers by which she is multiplying, adding, and subtracting and in which order these operations are occurring.

Input Specification

The first line of input is the number she feeds into the machine.

The second line of input contains two integers, separated by a space. The first integer indicates the value that must be added to the input at some point. The second integer indicates the time at which the adding operation will be executed (1 for first, 2 for second, and 3 for third).

The third line and fourth line are in the same format as the second line, but they relay information about the subtraction and multiplication operations respectively.

Output Specification

Output the final integer that is spit out the Munaras Magnificent Math Machine.

Sample Input

3 2
5 1
2 3

Sample Output



There are no comments at the moment.