Championship
InterviewTime limit2sMemory limit1024 MB
Given N team names, output the team numbers in the table order that makes the concatenated name string lexicographically smallest.
Statement
A football league in a large but rather cold northern country has teams competing against each other. Each team has its own name that reflects the spirit and history of the team. Each team has a fan club whose members follow every match and support the team through both great wins and painful losses. At any moment, each fan can name the squad, the goals of each player, the goals scored and conceded, the schedule of the remaining matches, and the result of any match already played.
Every fan also knows the current standings. Each fan knows where every team stands, and can say which team is third and which is eighth at any time.
One morning, after a win by his favorite club, Ivan woke up and realized he could not remember the table at all. He only remembered the names of all teams in the championship. Over a strong cup of coffee he recalled a curious fact he had noticed while arguing about the table with other fans. If the team names are written one after another in the order they appear in the table, the resulting string is lexicographically smaller than the string obtained from any other order. For example, if only "Dinamo-Kiev", "Dinamo-Moskva" and "Amkar" took part, Ivan could easily say that Amkar is first, Dinamo-Kiev is second, and Dinamo-Moskva is third. But there are other teams too, and Ivan could not reconstruct the order. He asked you for help.
Input
The first line contains one integer (), the number of teams. The next lines list the team names. Each name is a string of lowercase Latin letters with length at most 20.
Output
Print lines. Each line contains the number of the team that occupies the corresponding position. The team numbers in the answer must not repeat. If there are several answers, you may print any of them. Teams are numbered from 1 in the order they appear in the input.