The Khoikhoi are a people from Southern Africa. Public Domain by Samuel Daniell on Wikmedia Commons Despite being barred from speaking at the Boring Annual Palindrome Convention for being too progressive, your girlfriend Jeannetta has continued her research on dralinpomes. A dralinpome is, of course, a word in which the letters can be rearranged to form a palindrome. For example, khoikhoi is a dralinpome, because you can rearrange the letters to form the string khoiiohk, which is a palindrome, since it reads the same forwards and backwards.
Last year, Jeannetta found all the dralinpomes in the dictionary, but she's not satisfied yet. Luckily, she discovered that in Dutch, you can concatenate nouns to make a compound word. Even if it means setting a stand somewhere in a dark corner outside of the convention center, people have to hear her breakthrough talk How the Dutch Dominate Dralinpomes!
Unfortunately, Jeannetta is not quite satisfied with her talk. The longest dralinpome she could come up with was khoikhoihuttententoonstellingsbudgetbeheerder (treasurer for the famously long exposition of African housings), with only $$$45$$$ characters! She's fairly sure no one will show up to her talk without a longer example, so she has asked you to help.
Given a list of $$$n$$$ nouns, determine the longest dralinpome that can be formed by concatenating some of them. You may use each noun no more times than it is provided.
The input consists of:
If it is possible to form a dralinpomic compound word, output "possible" followed by a longest possible such word. Otherwise, output "impossible".
If there are multiple valid solutions, you may output any one of them.
2 multinomiaal coefficient
possible multinomiaalcoefficient
5 auto band ventiel dopjes fabriek
impossible
7 khoikhoi soldaten hutten tentoonstellings terreinen budget beheerder
possible khoikhoihuttententoonstellingsbudgetbeheerder
3 ei ei ei
possible eiei