Once Kazama had written a basic calculator, he read further about other operators and operator precedence. Now he is writing a new calculator with following details:
- Binary addition: .
- Binary subtraction:
- Multiplication:
- Division:
- Unary operators: and
- Brackets:
Operator precedence
Associativity
Now all operators are right associative. That is , or
Formally it has following grammar:
Expression ::= Term [+-] Expression
| Term
Term ::= Factor [*/] Term
| Factor
Factor ::= Number
| [+-] Factor
| '(' Expression ')'
He needs your help to verify it. He wants you to solve some expressions for him using the above grammar and he will cross check the results. Since you are also lazy, you will write another computer program which will solve the expressions. Since the output value can be too large, you have to tell output modulo .
Note:
- is a prime.
Input Format
Input will contain a valid expression.
Constraints
- Length of expression will not exceed .
- There can be or more whitespaces between operators/operands.
- Tests are designed such that there will be no divide by zero case.
- Each factor will be accompanied by at-most one unary operator. That is "" is an invalid case.
Output Format
Print the result of expression modulo
Sample Input 0
22 * 79 - 21
Sample Output 0
1717
Sample Input 1
4/-2/2 + 8
Sample Output 1
4
Sample Input 2
55+3-45*33-25
Sample Output 2
999998605
Sample Input 3
4/-2/(2 + 8)
Sample Output 3
999999987
Explanation
Sample Case 0:
.
Sample Case 1:
Sample Case 2:
Sample Case 3: