Catarina loves playing ARPGs, specifically Diablo-style games, and spent all of Winter break playing them. One thing in common with a lot of these games is their item system: each item has at most damage modifiers (mods), each of which is one of three types:
X added damage: this mod adds a flat amount of damage.
Y increased damage: this mod increases the base damage by .
Z more damage: this mod increases the total damage by .
Damage calculation is then performed as follows: first, all the flat damage mods are added together to determine the item’s base damage. Then, the increased damage mods are applied additively to the base damage value. Finally, the more damage mods are applied multiplicatively to the resulting damage value.
For example, suppose an item has the following mods:
40 added damage
60 added damage
30 increased damage
20 increased damage
100 more damage
100 more damage
This item has a base damage of , which is then increased by , giving it a total of damage. The more multipliers then give it a total of damage.
All this confusion makes comparing the damage of different items very difficult, so Catarina has asked for your help to write a program that determines an item’s damage. Can you help her out?
The first line of input contains an integer , the number of modifiers on an item. The next lines each contain a damage modifier in the format described above.
Output the total damage of the item. Your output will be considered correct if it has an absolute or relative error of at most .
Sample Input 1
6 40 added damage 60 added damage 30 increased damage 20 increased damage 100 more damage 100 more damage
Sample Output 1
Sample Input 2
2 100 increased damage 100 more damage
Sample Output 2