A marketing company called ACM produces all sorts of quirky promotional items that are handed out to customers and business partners as small gifts. One of its specialties is a calculator that works with Roman numerals.
Roman numerals can express any non-negative integer using uppercase letters:
| Symbol | I | V | X | L | C | D | M |
|---|---|---|---|---|---|---|---|
| Value | 1 | 5 | 10 | 50 | 100 | 500 | 1000 |
A number is written by placing letters next to one another, and a letter of higher value must always come before letters of lower value. The only exceptions are the letters "I", "X", and "C": each may be placed before a higher letter to form a value whose last digit is 4 or 9. The only allowed combinations are:
| Combination | IV | IX | XL | XC | CD | CM |
|---|---|---|---|---|---|---|
| Value | 4 | 9 | 40 | 90 | 400 | 900 |
Every Roman numeral must express thousands first, then hundreds, then tens, and finally ones. Therefore 499 must always be written as "CDXCIX", never as "ID".
Although not very practical, this gift is considered extremely cool. Your task is to write the software for this calculator.
The input consists of commands, each written on its own line. The possible commands are assignments, "RESET", and "QUIT".
An assignment command begins with a single digit that names one of the calculator's ten registers (0 through 9). The register number is followed by an equals sign ("=") and an expression. The expression contains only valid Roman numerals, register names (single digits), and the plus ("+") and minus ("-") signs. You may assume that every expression is valid and no longer than 10000 characters.
The "QUIT" command is always the last command in the input.
For each command, print exactly one line.