The Writers' Club is an online community where writers and lovers of short stories meet to publish, read, and discuss stories. Like any community site, every reader keeps a personal list of favorite writers.
The maintainers noticed a pattern: readers tend to like the writers that their own favorite writers like. For example, if John favors the writer Alice (John reads and likes Alice's stories), then many readers who favor John also come to favor Alice — and, in turn, Alice's favorite writers, their favorite writers, and so on.
The site wants a recommendation service based on this idea. Continuing the example, it would recommend Alice — together with Alice's favorite writers, their favorite writers, and so on — to every reader who favors John. A user may act both as a writer (someone with admirers) and as a reader (someone with favorites). The service must never recommend a writer that the receiving reader already favors, and never recommend a writer to that same writer.
The input contains one or more test cases. The first line of a test case has two positive integers $T$ and $N$, where $T$ is the total number of users ($T \le 100{,}000$) and $N$ is the number of writers ($N \le 100$).
Then follow $N$ lines, one per writer. Each line holds one or more names: the first is the writer's name and the rest are that writer's admirers (the readers who favor the writer):
writer admirer1 admirer2 ... admirerd
A name is a string of 1 to 16 lowercase letters, and all names are unique within a test case. Names are separated by one or more spaces.
The input ends with a line containing two zeros: 0 0.
For each test case, first print a header line:
--- CASE k
where k is the test-case number, starting from 1 (the header is three minus signs, a space, the word CASE, a space, and k).
After the header, print zero or more lines, one per recommended writer, in the form:
writer reader1 reader2 ...
Here writer is a writer being recommended, and reader1 reader2 ... are the readers to whom that writer is recommended. Sort the lines alphabetically by writer name, and within each line sort the readers alphabetically. A writer is never recommended to itself, nor to any reader who already favors that writer. All names on a line are separated by a single space.