After Voldemort and the Death Eater were wiped out by Harry Potter and his friends, Harry becomes the glory of the Wizarding World, magician treat him as model, hero, king… and much more than that.
Recently Harry Potter and his friends have been researching a kind of toy from the Muggle World, with the name Cyber Sequence Generator, wondering if after manipulated in some certain way, it can be useful and powerful for magicians.
This kind of generator has two magic containers C1 and C2, if we put a magic element in C1, after its magic is all over, the result magic element can be taken from C2. Because we Muggles(I’m sorry if you are not a muggle, you can ask me for magic student version of this problem statement even you are competing and can’t use the Internet) do not know magic languages, let’s rearrange the words to describe how the generator works.
The generator’s work can be split into simple works. Each work is like:
SET|ADD C1|C2, C1|C2|IntegerNumber
MUL C1|C2, IntegerNumber
By “SET a,b “, we have the value of the element in container a changed to b
By “ADD a,b “, we have the value of the element in container a added by b
By “MUL a,b “, we have the value of the element in container a multiplied by b
After each of the operations, the value in b will not change.
Here C1, C2 denotes actually the value of magic element.
C2’s initial value is 0.
All works are done in the order in input.
Harry always has a magic element V at first, and can use the generator arbitary times, and wonders if so, what is the value of the result element.