# Problem S. 7. (March 2005)

**S. 7.** Given a set of words, each of length between 5 and 30 letters. Write a program to sort them such that the last 5 letters of each word matches the first 5 letters of the next one. The number of words is at most 10,000 and only the 26 lower case letters of the English alphabet are used.

The first line of the input contains the number of words; then each subsequent line contains one word. If there exists a proper sorting, write one to the output such that each line contains one word. If there is no solution, just display `NO SOLUTION`.

(10 pont)

**Deadline expired on April 15, 2005.**

### Statistics:

4 students sent a solution. 10 points: Nikházy László , Stippinger Marcell. 5 points: 1 student. 0 point: 1 student.

Problems in Information Technology of KöMaL, March 2005