A palindrome is a string of characters which can be read forward and backward and still result in the same word, e.g. `mumdadmum'. So by definition the empty string, all strings containing 1 character, and all strings containing 2 equal characters are palindromes. The length of a palindrome is the number of characters in the palindrome.
A palinword is a string of characters that contains at least 2 different palindromes each with a length of at least 3. (Here the position is immaterial: the same palindrome occurring in another position is not considered as different.) Neither of these 2 palindromes may be embedded in the other palindrome (for example the palindrome `mum' is embedded in the palindrome `amuma', and `aaa' is embedded in `aaaa') but they may partially overlap. Also see the examples below.
Your program's task is to copy only the palinwords from the input file to the output file.
The input for your program is a textfile. Each line in this file is empty or consists of one or more words (uppercase letters `A' through `Z' only) separated by one or more spaces (each line in the input file contains at most 255 characters in all).
The output file is a textfile and must have one palinword per line in order of occurrence in the input file.
MOEILIJKHEDEN INVOER VERNEDEREN AMUMA AMAMA MUMMUM AMATRAMA AAAA ABATRABAR DUMMY WORDS
MOEILIJKHEDEN VERNEDEREN AMAMA MUMMUM