Chronogram

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

A chronogram is an inscription (usually found on monuments) in which the year of the event commemorated by the monument is encoded. The year is obtained by adding up all the values of those letters that can appear in Roman numerals. Values of individual letters:

  • I … 1
  • V … 5
  • X … 10
  • L … 50
  • C … 100
  • D … 500
  • M … 1000

Chronograms are usually studied by theologians. As a part of a study of great importance in the Central Europe, they compiled a long list of chronograms. The monks would like to make sure they do not make any mistake in calculating the corresponding years and therefore decided to use a computer program. Since monks are not skilled programmers, they urgently need your help.

Write a program that will extract the year of the event from a chronogram.

입력

The first line of the input contains an integer TT, i.e. the number of test cases. This is followed by TT lines; each line contains one chronogram that contains at most 1000 characters. The text contains only uppercase letters of the English alphabet and spaces.

출력

For each chronogram output one integer, i.e. the year encoded in the chronogram.

제한

  • 1T100001 \leq T \leq 10000

  • Every line contains at most 1000 characters.

  • A character may be an uppercase letter of the English alphabet or a space.