Let's play "balda"!
What do students do during a lecture when they need to appear attentive but don't feel like participating? Naturally, they play "balda." In this game, players must form as many words as possible using the letters from a single word. The longer the words, the more points a player earns. Therefore, the most valuable words are those that can be formed by rearranging the letters of the given word. You can even combine fun with learning by playing the game in English—at least you'll gain some benefit from "balda"!
Clever Dima decided to write a program to generate templates for playing "balda." By studying these templates, Dima plans to outsmart all his classmates while also expanding his English vocabulary. Dima aims to print groups of words formed by rearranging letters. Since there might be too many such groups, Dima decided to print only the first five with the most words. If there are fewer than five groups in the dictionary, Dima will print them all.
Could you create such a program for yourself? It might prove useful!
Input
The input file contains a list of words, with each word on a separate line. Each word is no longer than 40 characters. The file contains no more than 25000 words.
Output
Print the first five largest groups of words. Within each group, list all the words in lexicographical order. If there are fewer than five groups, print all available groups. Sort the groups by the number of words they contain. If multiple groups have the same size, sort them in lexicographical order. Be sure to pay very close attention to the output format in the example to avoid errors!