The students in the ACM class have to re-select their partners, and every two students form a study group. In order to simply group them, the teacher sorts them according to each person's birthday, numbering them from 1 to n. If the birthday is the same, sort in the lexicographical order of the names.
The lexicographical order on the set of all these finite words orders the words as follows:
-
Given two different words of the same length, say $a = a_1a_2...a_k$ and $b = b_1b_2...b_k$, the order of the two words depends on the alphabetic order of the symbols in the first place i where the two words differ (counting from the beginning of the words): a < b if and only if $a_i < b_i$ in the underlying order of the alphabet A.
-
If two words have different lengths, the usual lexicographical order pads the shorter one with "blanks" (a special symbol that is treated as smaller than every element of A) at the end until the words are the same length, and then the words are compared as in the previous case.
Now let $a_i$ be the i-th classmate, then $a_i$ and $a_{n-i+1}$ must have a partner relationship. The students are very naughty. Even if some people don’t know the hour and minute of the birth time, they still report the content to the teacher.
Please help the teacher arrange each person’s partner. The teacher only needs the ranking of the students, so you need to output the names of the students after the ranking. In addition, the teacher wants to know how many minutes each person’s birthday differs from their partner’s birthday.