#C2455. Combinable Words

    ID: 45773 Type: Default 1000ms 256MiB

Combinable Words

Combinable Words

Given a list of words, determine those words which can be formed by the concatenation of exactly two other words from the same list. In other words, for a word \(W\) to be considered combinable, there must exist non-empty strings \(A\) and \(B\) such that \(W = A + B\), and both \(A\) and \(B\) are present in the word list.

The input consists of multiple datasets. For each dataset, if a combinable word is found, output it (or them, in their original order) on separate lines. If no combinable word can be found in a dataset, output "No combination found". Separate outputs for different datasets with an empty line.

inputFormat

The input is read from standard input and consists of multiple datasets. Each dataset starts with a positive integer \(n\) (given on a line by itself) indicating the number of words in that dataset, followed by \(n\) lines each containing a word. The sequence of datasets ends with a line containing a single zero ("0").

outputFormat

For each dataset, output each combinable word on its own line. If a dataset has more than one combinable word, maintain their original order as given in the input. If a dataset does not contain any combinable word, print "No combination found". Separate the output for different datasets with an empty line.

## sample
4
star
wars
starwars
light
4
light
house
lighthouse
pillar
0
starwars

lighthouse

</p>