Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Naming Convention

By akash.kuet · Limits 1s, 512 MB

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

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≤N≤1000

1≤Each string length≤100

Output

Output list of words which follows Voogle’s function naming convention or “No solution”.

Sample

InputOutput
5
a ab ac aa acab
aa acab

aa contains a twice and acab contains ac and ab.

Discussion

Statistics


37% Solution Ratio

code_hard123Earliest, 3w ago

not_OPFastest, 0.0s

mahdi.hasnatLightest, 131 kB

probableShortest, 601B

Submit

Login to submit

Editorial

You are given a list of strings and you have to find out which strings can be made of concatenating ... Read more...

Related Contests

Criterion 2020 Round 4 Ended at 2020-03-13 11:30:00 +0000 UTC