青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

Yiner的ACM

成長的痕跡
<2011年4月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

統計

  • 隨筆 - 29
  • 文章 - 0
  • 評論 - 2
  • 引用 - 0

常用鏈接

留言簿(1)

隨筆分類

隨筆檔案

搜索

  •  

最新評論

閱讀排行榜

評論排行榜

字符串處理 A-Metsys Laremun

 

Prof. Hachioji has devised a new numeral system of integral numbers with four lowercase letters "m", "c", "x", "i" and with eight digits "2", "3", "4", "5", "6", "7", "8", "9". He doesn't use digit "0" nor digit "1" in this system.

The letters "m", "c", "x" and "i" correspond to 1000, 100, 10 and 1, respectively, and the digits "2", ...,"9" correspond to 2, ..., 9, respectively. This system has nothing to do with the Roman numeral system.

For example, character strings

"5m2c3x4i", "m2c4i" and "5m2c3x"

correspond to the integral numbers 5234 (=5*1000+2*100+3*10+4*1), 1204 (=1000+2*100+4*1), and 5230 (=5*1000+2*100+3*10), respectively. The parts of strings in the above example, "5m", "2c", "3x" and "4i" represent 5000 (=5*1000), 200 (=2*100), 30 (=3*10) and 4 (=4*1), respectively.

 

Each of the letters "m", "c", "x" and "i" may be prefixed by one of the digits "2", "3", ..., "9". In that case, the prefix digit and the letter are regarded as a pair. A pair that consists of a prefix digit and a letter corresponds to an integer that is equal to the original value of the letter multiplied by the value of the prefix digit.

For each letter "m", "c", "x" and "i", the number of its occurrence in a string is at most one. When it has a prefix digit, it should appear together with the prefix digit. The letters "m", "c", "x" and "i" must appear in this order, from left to right. Moreover, when a digit exists in a string, it should appear as the prefix digit of the following letter. Each letter may be omitted in a string, but the whole string must not be empty. A string made in this manner is called an MCXI-string.

An MCXI-string corresponds to a positive integer that is the sum of the values of the letters and those of the pairs contained in it as mentioned above. The positive integer corresponding to an MCXI-string is called its MCXI-value. Moreover, given an integer from 1 to 9999, there is a unique MCXI-string whose MCXI-value is equal to the given integer. For example, the MCXI-value of an MCXI-string "m2c4i" is 1204 that is equal to 1000 + 2*100 + 4*1. There are no MCXI-strings but "m2c4i" that correspond to 1204. Note that strings "1m2c4i", "mcc4i", "m2c0x4i", and "2cm4i" are not valid MCXI-strings. The reasons are use of "1", multiple occurrences of "c", use of "0", and the wrong order of "c" and "m", respectively.

Your job is to write a program for Prof. Hachioji that reads two MCXI-strings, computes the sum of their MCXI-values, and prints the MCXI-string corresponding to the result.

Input

The input is as follows. The first line contains a positive integer n (<= 500) that indicates the number of the following lines. The k+1 th line is the specification of the k th computation (k=1, ..., n).

n
specification1
specification2
...
specificationn

Each specification is described in a line:

MCXI-string1 MCXI-string2

The two MCXI-strings are separated by a space.

 

You may assume that the sum of the two MCXI-values of the two MCXI-strings in each specification is less than or equal to 9999.

Output

For each specification, your program should print an MCXI-string in a line. Its MCXI-value should be the sum of the two MCXI-values of the MCXI-strings in the specification. No other characters should appear in the output.

Sample Input

10
xi x9i
i 9i
c2x2i 4c8x8i
m2ci 4m7c9x8i
9c9x9i i
i 9m9c9x8i
m i
i m
m9i i
9m8c7xi c2x8i

Sample Output

3x
x
6cx
5m9c9x9i
m
9m9c9x9i
mi
mi
mx
9m9c9x9i

posted on 2011-03-20 19:37 Yiner 閱讀(217) 評論(0)  編輯 收藏 引用

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久青草欧美一区二区三区| 香蕉亚洲视频| 亚洲精品视频啊美女在线直播| 久久九九99| 在线观看日韩国产| 亚洲三级毛片| 国产精品久久久久久久久久ktv| 午夜在线观看欧美| 国产精品久久久久av| 欧美日韩视频在线第一区| 久久影院午夜片一区| 欧美国产丝袜视频| 欧美成人精品三级在线观看| 欧美久色视频| 激情欧美亚洲| 99在线精品视频| 久久国产成人| 国产亚洲一区二区三区在线观看| 久久午夜视频| 在线精品一区二区| 国产视频在线观看一区二区| 小辣椒精品导航| 亚洲女人av| 新狼窝色av性久久久久久| 老牛国产精品一区的观看方式| 久久久久免费观看| 欧美国产视频一区二区| 欧美区日韩区| 欧美精品日韩www.p站| 久久精品国产免费看久久精品| 亚洲激情一区二区三区| 欧美一区二区观看视频| 久久精品国产91精品亚洲| 欧美国产综合视频| 亚洲视频在线观看视频| 久久免费的精品国产v∧| 欧美视频二区36p| 黄色在线一区| 亚洲欧美中文字幕| 亚洲国产日韩美| 久久精品成人欧美大片古装| 欧美日韩一区免费| 亚洲日本成人| 麻豆精品91| 午夜精品福利一区二区三区av| 欧美va亚洲va国产综合| 国产亚洲一级| 欧美在线一二三| 一区二区三区回区在观看免费视频| 欧美一区二区三区免费在线看| 欧美吻胸吃奶大尺度电影| 亚洲区一区二| 欧美高清视频一区| 久久婷婷国产麻豆91天堂| 国产人成精品一区二区三| 在线视频免费在线观看一区二区| 亚洲国产黄色| 欧美精品一区视频| 9i看片成人免费高清| 亚洲国产欧美在线| 欧美精品一区二区久久婷婷| 亚洲全黄一级网站| 欧美国产精品久久| 美女黄毛**国产精品啪啪 | 狂野欧美激情性xxxx| 午夜精品av| 激情五月***国产精品| 老司机精品视频一区二区三区| 欧美在线观看日本一区| 国产一区二区三区在线观看精品| 欧美日韩成人在线播放| 亚洲伦理在线| 亚洲麻豆视频| 欧美午夜不卡在线观看免费 | 国产日韩欧美二区| 久久成人国产| 久久久久久久综合日本| 亚洲福利久久| 亚洲精品影院| 国产一区二区久久| 欧美激情一区| 欧美三级黄美女| 久久高清福利视频| 久久偷看各类wc女厕嘘嘘偷窃| 亚洲国产精品va在线看黑人动漫| 亚洲欧洲美洲综合色网| 国产精品久久一级| 欧美成人xxx| 欧美日韩国产影片| 久久成人久久爱| 免费在线国产精品| 亚洲影院在线| 久久亚洲一区| 亚洲与欧洲av电影| 久久综合色天天久久综合图片| 夜夜嗨av一区二区三区四区| 亚洲综合成人在线| 亚洲欧洲日本在线| 午夜亚洲一区| aⅴ色国产欧美| 久久成人免费| 亚洲女爱视频在线| 欧美福利视频| 久久影视三级福利片| 欧美日韩午夜剧场| 久久亚洲精品网站| 国产精品美女黄网| 最新69国产成人精品视频免费| 国产乱子伦一区二区三区国色天香| 另类成人小视频在线| 欧美四级电影网站| 亚洲第一精品夜夜躁人人爽| 国产免费成人| 99亚洲视频| 亚洲黄色在线视频| 久久精品30| 久久国产色av| 国产精品久久午夜| 亚洲久久成人| 亚洲国产专区校园欧美| 欧美中日韩免费视频| 欧美亚洲视频在线看网址| 欧美日韩亚洲视频一区| 欧美高清视频免费观看| 尤妮丝一区二区裸体视频| 亚洲一区二区三区视频播放| 99视频一区| 欧美xart系列在线观看| 亚洲免费在线观看视频| 欧美日韩中文字幕综合视频| 91久久精品国产91久久性色tv | 国产亚洲美州欧州综合国| 亚洲黄色av一区| 最新中文字幕亚洲| 麻豆成人小视频| 嫩模写真一区二区三区三州| 国产精品一区二区在线| 亚洲一区一卡| 欧美亚洲日本一区| 国产欧美日韩视频一区二区三区| 9色国产精品| 亚洲综合日韩在线| 国产美女精品在线| 久久久久高清| 亚洲国产成人久久综合| 99这里有精品| 国产精品亚洲视频| 久久经典综合| 亚洲国产精品久久久久婷婷老年 | 久久久精品日韩欧美| 国产午夜精品福利| 久久久青草青青国产亚洲免观| 久久这里只精品最新地址| 在线成人中文字幕| 欧美激情在线观看| 亚洲丝袜av一区| 久久久精品欧美丰满| 亚洲欧洲精品一区二区| 欧美三级视频在线播放| 亚洲欧美日韩国产另类专区| 久久欧美肥婆一二区| 最新国产成人在线观看| 国产精品wwwwww| 久久精品九九| 日韩午夜电影在线观看| 欧美一区二区| 亚洲国产日韩欧美| 国产精品老牛| 久久一区中文字幕| 一本色道精品久久一区二区三区| 久久精品免费| 99精品国产福利在线观看免费| 国产精品久久77777| 久久久综合网站| 亚洲天天影视| 亚洲国产日韩欧美一区二区三区| 午夜一区二区三视频在线观看| 亚洲国产成人在线播放| 国产精品白丝黑袜喷水久久久| 久久伊人一区二区| 午夜精品久久久久久久99水蜜桃| 欧美激情亚洲视频| 久久久久久久久综合| 夜色激情一区二区| 亚洲高清久久网| 国产三区精品| 欧美丝袜一区二区| 欧美高清视频www夜色资源网| 亚洲影院免费观看| 亚洲欧洲日本mm| 欧美激情一二区| 久久人人超碰| 欧美亚洲午夜视频在线观看| 日韩亚洲成人av在线| 精品动漫一区| 国产亚洲制服色| 国产精品欧美风情| 欧美日韩在线一区二区| 模特精品裸拍一区| 久久久久久亚洲精品不卡4k岛国|