Time limit
1s
Memory limit
128 MB
Roman numerals write natural numbers with the seven symbols I, V, X, L, C, D, and M.
| Symbol | I | V | X | L | C | D | M |
|---|---|---|---|---|---|---|---|
| Value | 1 | 5 | 10 | 50 | 100 | 500 | 1000 |
A valid Roman numeral follows these rules.
Given two numbers written as Roman numerals, output their sum as an Arabic numeral and as a Roman numeral.
The first and second lines each contain one number written as a Roman numeral. Each input number is at most 2000, and their sum is less than 4000.
On the first line, output the sum as an Arabic numeral. On the second line, output the same value as a Roman numeral.