407110: GYM102697 081 It's a Mess!
Description
You have an in-home library, but its organization is a mess! Fantasy books next to non-fiction biographies, detective novels next to ancient classics, and worst of all, the author's names aren't in alphabetical order!
To fix this problem, you decide to create a program that is able to divide the books into different genre groups, with the authors of the genres listed in alphabetical order.
InputThe first line will contain the number of books that are in the library, and the following lines will contain books in this format, with the author's last name as the first word, and the genre as the second word, with both being separated by a space.
OutputOutput a line of string that will contain a single Genre, and the list of authors writing in that genre in alphabetical order, in this format: <genre>: <aauthor1>, <bauthor>, <cauthor>
ExampleInput7 Bradbruy scifi Asimov scifi Kafka dystopian Huxley dystopian Tolkien fantasy Collins dystopian Herbert scifiOutput
dystopian: Collins, Huxley, Kafka fantasy: Tolkien scifi: Asimov, Bradbruy, HerbertNote
(For the order of the genres, please make sure that they are also in alphabetical order.)
(It can also be assumed that all genres and authors will contain one word, but last names will have proper capitalization conventions.)