#C8294. Count Books by Genre

    ID: 52260 Type: Default 1000ms 256MiB

Count Books by Genre

Count Books by Genre

You are given a list of book details. Each book detail is provided as a single line containing the book ID (a positive integer), the title and the genre separated by commas. The genre is guaranteed to be one of the following: Fiction, Non-Fiction, Mystery, or Science Fiction. Your task is to count the number of books in each genre and output the result in the order: Fiction, Non-Fiction, Mystery, and Science Fiction.

In mathematical terms, if we let \(f\), \(nf\), \(m\), \(sf\) denote the counts of Fiction, Non-Fiction, Mystery, and Science Fiction books respectively, then you need to compute: \[ \begin{aligned} f &= \text{number of books where genre = 'Fiction'}, \\ nf &= \text{number of books where genre = 'Non-Fiction'}, \\ m &= \text{number of books where genre = 'Mystery'}, \\ sf &= \text{number of books where genre = 'Science Fiction'} \end{aligned} \] and output the four numbers separated by a space.

Note: The input is provided via standard input (stdin) and the output must be printed to standard output (stdout).

inputFormat

The input will begin with an integer \(n\) on the first line representing the number of books. Each of the following \(n\) lines contains a book detail with the format:

book_id,title,genre

where book_id is a positive integer, title is a string (it may contain spaces but will not contain commas), and genre is one of the fixed strings: Fiction, Non-Fiction, Mystery, or Science Fiction.

outputFormat

Output a single line containing four integers separated by a space. These numbers represent the counts of books for Fiction, Non-Fiction, Mystery, and Science Fiction respectively.

## sample
2
1,The Great Gatsby,Fiction
2,To Kill a Mockingbird,Fiction
2 0 0 0