solution to print all anagrams together