Tony works in a multinational technology company named Voogle LLC. The employees of Voogle follow certain rules to name a function. They have a list of unique function names and each name contains lowercase letters. But they will choose names which consisted entirely of at least two names from the list. Suppose if the list contains function names such as “sum”, “add”, “addsum”, they will choose “addsum” name because it is made of concatenation of “add” and “sum”.
So you are given a list of words. You have to find out words which are made of concatenation of at least two words from the list. Print the words so that their relative order is maintained from the input list. If no words are found, then print “No solution”.
Input starts with an integer N, the number of names the list contains. In the next line there are N words, each character of the word contain lowercase letters.
1≤Each string length≤100
Output list of words which follows Voogle’s function naming convention or “No solution”.
5 a ab ac aa acab
aa contains a twice and acab contains ac and ab.