You are given a list of N distinct words.
Find the longest word in the list that can be obtained by concatenating other words from the list. Any word can be used multiple times in the concatenation.
The first line of input contains an integer N.
Each of the following N lines contains a word.
The only line of output should contain the longest word with the required property, or -1 if no such word exists.
- 1 ≤ N ≤ 100
- Each word contains at most 100 lowercase letters from the English alphabet.
- If a solution exists, it is guaranteed to be unique.