Problem Description

Read q operations on x starting with 0. Operations are ADD v, MUL v, and MOD m. Values can be large. Use big integers safely and output final x.

Input Format

First line q. Next q lines: op value.

Output Format

One integer x.

Sample Test Case

Input:
5 ADD 999999999999999999 MUL 2 MOD 1000 ADD 7 MUL 3
Output:
21

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next