Munara has created a Magnificent Math Machine. Her machine will take any integer, , and perform 3 operations on it: addition, multiplication, and subtraction.
Each time she feeds a number, , 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
5
3 2
5 1
2 3
Sample Output
6
Comments