Ave, Mvnde! (ave.X)
Farmer Alvarado has decided to teach all of the inhabitants of her farm Latin. As a first lesson, she is designing a friendly and welcoming lesson in Roman number representation for her bovis (that's "cows" in Latin) to study.
FA has told her favorite bos ("cow"), named Bessie, that Bessie will be rounding up the class from around the farm. In order to emphasize the importance of using Latin in real-world situations, FA will communicate only in Roman numerals. In particular, she will send Bessie a note with a roman numeral on it, and Bessie will have to invite that many cows to the day's Latin class. Your task is to help Bessie round up those cows!
PROBLEM NAME: ave.X
As a guide, Roman numerals use only these letters with their corresponding values:
letter: I value: 1
letter: V value: 5
letter: X value: 10
letter: L value: 50
letter: C value: 100
letter: D value: 500
letter: M value: 1000
Although variants exist, FA is a stickler for the official interpretation of roman numerals (as expressed at Cowipedia):
"Generally, Roman numerals are written in descending order from left to right, and are added sequentially, for example MMVI (2006) is interpreted as 1000 + 1000 + 5 + 1.
Certain combinations employ a subtractive principle, which specifies that where a symbol of smaller value precedes a symbol of larger value, the smaller value is subtracted from the larger value, and the result is added to the total. For example, in MCMXLIV (1944), the symbols C, X and I each precede a symbol of higher value, and the result is interpreted as 1000 plus (1000 minus 100) plus (50 minus 10) plus (5 minus 1).
A numeral for 10**n (I, X, or C) may not precede a numeral larger than 10**(n+1), where n is an integer. That is, I may precede V and X, but not L or C; X may precede L or C, but not D or M. In addition, the same numeral for 10**n (M, C, X, I) may not appear more than three times in a row. That is, MMMM or IIII would not be allowed (same numeral), but MCMX is OK, because it follows the other rules.
The numerals 5*10**n (V, L, or D) may not be followed by a numeral of greater or equal value. Also, any symbol that appears more than once consecutively may not be followed by a symbol of larger value."
Help Bessie with this task by writing a program that prints "Ave, Mvnde!" - the traditional bovine greeting for inviting a cow to Latin class - the appropriate number of times.
If an input roman numeral does not follow the rules above, your program should output the string "nocens numerus" ("bad number" in Latin).
SAMPLE INPUT:
IV
INPUT DETAILS:
The input is a valid representation of 4 in roman numerals. The input comes from stdin.
SAMPLE OUTPUT:
Ave, Mvnde!
Ave, Mvnde!
Ave, Mvnde!
Ave, Mvnde!
OUTPUT DETAILS:
Four instances of the string "Ave, Mvnde!" are printed to stdout.
If an invalid input had been seen, a single string
nocens numerus
would have been the appropriate output.