P12780 [HackerEarth] direrctory
普及
题目描述

Lexicographical order is a generalization of the way the alphabetical order of words is based on the alphabetical order of their component letters. An example of lexicographical arrangement is a dictionary or a contact directory.

You are given some names, and your task is to arrange these names in lexicographical order. The interesting part is that some of these names contain roman numerals at end like Louis IV and Henry VII. Take care of these roman numerals as well in correct mathematical order i.e. I<II<III,IV and so on.

INPUT

First line of Input contains a single integer N denoting the number of lines to be followed.

Next N lines contains the names to be arranged. Each line contains a single name.

OUTPUT

N lines, each containing a single name arranged in lexicographical manner.

Constraints

1 ≤ N ≤ 50

Length of a name will be between 1 to 30 characters

No two names will be sameSAMPLE INPUT
4
Henry IX
Louis V
Henry VIII
Charles II

SAMPLE OUTPUT
Charles II
Henry VIII
Henry IX
Louis V

输入格式

见题面

输出格式

见题面

样例输入
Bruce XXII Henri XX Maru XXXVI Philippe XL Lou XVI Lovro XVI Kubus XXXII Maru XXXIX Bob XXXVIII Richard XXXIX Carlos II James XXXIII Anne XXIV Anne XXVI Philip XLVII Ilya III Kubus XLII Julka XIX Mary XLVII Lukas XVIII Zemco L Richard II Anicka XXXVII Genadij XXXII Ivan XXI Henri XXXI Pjotr III Philip XIII Elizabeth XXIX James XLV Zemco XXIX Fero XVI Lukas IX Bob XXXIII Pjotr XLV Lukas XXVII Dmytro XXVIII William XXII Carlos XLII Elizabeth XLIX Fero XI Philippe IV Elizabeth XXXI Victoria XXXVII John XXXIII Tomek IX Lukas XIV Tomek XXXIII
样例输出
Anicka XXXVII Anne XXIV Anne XXVI Bob XXXIII Bob XXXVIII Bruce XXII Carlos II Carlos XLII Dmytro XXVIII Elizabeth XXIX Elizabeth XXXI Elizabeth XLIX Fero XI Fero XVI Genadij XXXII Henri XX Henri XXXI Ilya III Ivan XXI James XXXIII James XLV John XXXIII Julka XIX Kubus XXXII Kubus XLII Lou XVI Lovro XVI Lukas IX Lukas XIV Lukas XVIII Lukas XXVII Maru XXXVI Maru XXXIX Mary XLVII Philip XIII Philip XLVII Philippe IV Philippe XL Pjotr III Pjotr XLV Richard II Richard XXXIX Tomek IX Tomek XXXIII Victoria XXXVII William XXII Zemco XXIX Zemco L