Back

Number Conversions

Worth 4 point(s) - Runtime Limit: 3 seconds

Introduction

Turns out there are more than one way to count numbers.

Write a program that accepts Roman numeral numbers and outputs the value in Arabic Numerals. Your program must handle the Roman numeral values M, D, C, L, X, V and I, in both upper and lower case. For example: CMI is 901 and MCMXCI is 1991.

Input

The first line contains \(N\), the number of test cases. Each test case consists of one line containing a string of roman numeral characters.

3
XII
XXXIX
DCXCIX

Output

Print out the Arabic Numeral representation of each roman numeral test case.

12
39
699