#P1575A. Another Sorting Problem
Another Sorting Problem
No submission language available for this problem.
Description
Andi and Budi were given an assignment to tidy up their bookshelf of books. Each book is represented by the book title — a string numbered from to , each with length . Andi really wants to sort the book lexicographically ascending, while Budi wants to sort it lexicographically descending.
Settling their fight, they decided to combine their idea and sort it asc-desc-endingly, where the odd-indexed characters will be compared ascendingly, and the even-indexed characters will be compared descendingly.
A string occurs before a string in asc-desc-ending order if and only if in the first position where and differ, the following holds:
- if it is an odd position, the string has a letter that appears earlier in the alphabet than the corresponding letter in ;
- if it is an even position, the string has a letter that appears later in the alphabet than the corresponding letter in .
The first line contains two integers and ().
The -th of the next lines contains a string consisting of uppercase Latin letters — the book title. The strings are pairwise distinct.
Output integers — the indices of the strings after they are sorted asc-desc-endingly.
Input
The first line contains two integers and ().
The -th of the next lines contains a string consisting of uppercase Latin letters — the book title. The strings are pairwise distinct.
Output
Output integers — the indices of the strings after they are sorted asc-desc-endingly.
Samples
Note
The following illustrates the first example.
