eolymp
bolt
Try our new interface for solving problems
Problems

Sort in reverse order

Sort in reverse order

Set of words is given. Sort them according to the following criteria.

Let a string a be less than a string b if the reverse of a string a is lexicographically less than the reverse of the string b. So a < b if reverse(a) < reverse(b). Here reverse is a reverse of the string. For example, reverse("Canteen") = "neetnaC", reverse("Home") = "emoH".

For example, "Home" < "Canteen", since "emoH" < "neetnaC".

However, there is a special word "ADAUniversity" in the text, that should always be at the start of the sorted list.

For words that have the same hash, their relative order must be preserved (implement a stable sort).

Input

The text contains a set of words. Each word consists of letters of Latin alphabet (lower and upper case). Only spaces can be present between the words. The number of words in the text does not exceed 1000. The length of each word does not exceed 100 characters.

Output

Print all words sorted according to the given condition. Each word should be printed on a separate line.

Time limit 1 second
Memory limit 128 MiB
Input example #1
  Canteen     pail
ADAUniversity     Home
 ADAUniversity  mother
Output example #1
ADAUniversity
ADAUniversity
Home
pail
Canteen
mother
Author Michael Medvediev