Problem D
Un-bear-able Zoo
Given an integer $n$, and $n$ lines describing animals, output in alphabetical order the animals Dr. Back has in his zoo, followed by their count.
Input
The input will contain multiple test cases, up to $5$. Each test case contains a line containing a single integer $n$ ($0 \le n \le 10^{3}$), followed by $n$ lines of animals with at least one word on every line. An animal name may consist of multiple lowercase or uppercase words, with the last one describing the kind of animal. Animal names may contain apostrophes, hyphens, and periods; e.g., St. Vincent’s Agouti would be a valid animal name. The input is terminated when $n$ is $0$.
Output
For each test case, output the list number, followed by the animals Dr. Back has in his zoo in lowercase and alphabetical order, with each animal followed by one space and the delimiter | and then another space and their count.
Sample Input 1 | Sample Output 1 |
---|---|
6 African elephant White tiger Indian elephant Siberian tiger Tiger Panda bear 1 Blue Russian Penguin 0 |
List 1: bear | 1 elephant | 2 tiger | 3 List 2: penguin | 1 |