COWBASIC
Bessie has created a new programming language, but without a compiler, she needs your help to run her programs.
COWBASIC is a straightforward and elegant language featuring two main operations: addition and loops. To prevent overflow, Bessie performs all addition operations modulo 10^9 + 7
. The MOO-loop allows a block of code to be executed a fixed number of times. Both loops and additions can be nested.
Your task is to determine the result of executing a given COWBASIC program and find the number it returns.
Input
You will receive a COWBASIC program consisting of no more than 100 lines, with each line containing up to 350 characters. A COWBASIC program is composed of a list of statements. There are three types of statements:
<variable> = <expression> <literal> MOO { <list of statements> } RETURN <variable>
Expressions can be of three types:
<literal> <variable> ( <expression> ) + ( <expression> )
A literal is a positive integer not exceeding 10^5
.
A variable is a string of up to 10 lowercase Latin letters.
It is guaranteed that a variable will not be used or returned by the RETURN statement before it is defined. The RETURN statement will appear only once, on the last line of the program.
Output
Output a single positive integer, which is the value of the variable specified in the RETURN statement.