Problem D
Typo
It is now far into the future and human civilization is ancient history. Archaeologists from a distant planet have recently discovered Earth. Among many other things, they want to decipher the English language.
They have collected many printed documents to form a dictionary, but are aware that sometimes words are not spelled correctly (typos are a universal problem). They want to classify each word in the dictionary as either correct or a typo. Naïvely, they do this using a simple rule: a typo is any word in the dictionary such that deleting a single character from that word produces another word in the dictionary.
Help these alien archaeologists out! Given a dictionary of words, determine which words are typos. That is, which words result in another word in the dictionary after deleting a single character.
For example if our dictionary is
However, if our dictionary is
Input
The first line of input contains a single integer
The next
The total length of all strings is at most
Output
Display the words that are typos in the dictionary. These should be output in the same order they appear in the input. If there are no typos, simply display the phrase NO TYPOS.
Sample Input 1 | Sample Output 1 |
---|---|
5 hoose hose nose noises noise |
hoose noises noise |
Sample Input 2 | Sample Output 2 |
---|---|
4 hose hoose oose moose |
hoose moose |
Sample Input 3 | Sample Output 3 |
---|---|
5 banana bananana bannanaa orange orangers |
NO TYPOS |