Library
Vasya has a home library with n books, and he wants to organize them based on the number of characters in each book's text. Your task is to assist him with this sorting challenge.
Input
The first line contains an integer n (1 ≤ n ≤ 1000), representing the number of books in the library. The following lines provide the details of each book. For the i-th book, the first line contains m[i]
, the number of lines in the book's text. The subsequent m[i]
lines contain the text of the book. Each book's text has a maximum of 300 characters and lines.
The lines consist of characters with ASCII codes ranging from ord(' ') to ord('z').
Output
Output the texts of the books sorted by the total number of characters, with each book's text separated by a line containing "***
". If two books have the same number of characters, they should remain in the order they appeared in the input.