The Japanese like to take photos. But photos taken with a digital
camera are not always sorted correctly on a computer. For example, a file
photo12.jpg
is for some reason put between files photo1.jpg
and photo2.jpg
,
and hence the photos are viewed in the wrong order. Some Japanese use a system
that sorts lines according to different, Japanese, rules, and in this case numbers
are sorted in the natural way.
Lexicographic order | Japanese order |
photo2
photox1
photox10
photox2
|
photo2
photox1
photox2
photox10
|
We will not give the Japanese rules in details here. They are rather simple and
logical. In order to determine these rules, just fill yourself with
the spirit of Japan.
Input
The input consists of several lines, which contain lowercase Latin letters and
digits only. The total amount of the input does not exceed 100 KB.
Output
Output the same lines sorted according to the Japanese rules.
In order to eliminate all ambiguities with respect to the Japanese rules,
you may use a reference program, which sorts according to these rules but has
some limitations: it sorts no more than 15 lines each of which is no longer than 30
symbols. The program is available
here.
Sample
input | output |
---|
photox10
photox1
photo2
photox2
| photo2
photox1
photox2
photox10
|
Problem Author: Vladimir Yakovlev
Problem Source: The 11th Urals Collegiate Programing Championship, Ekaterinburg, April 21, 2007