#C2594. Counting Themes with Multiple Books

    ID: 45927 Type: Default 1000ms 256MiB

Counting Themes with Multiple Books

Counting Themes with Multiple Books

Alice is managing her extensive collection of unique books, and she wants to group them by their themes. Each book is identified by its name and its theme. In each test case, you are given a list of books; your task is to determine the number of themes that have more than one book.

Constraints are given by (1 \le T \le 100) for the number of test cases and (1 \le N \le 1000) for the number of books per test case. The book name and theme lengths do not exceed 100 characters.

inputFormat

The input starts with an integer (T), representing the number of test cases. For each test case, the first line contains an integer (N), the number of books. This is followed by (N) lines, each containing two strings: the book name and its theme.

outputFormat

For each test case, output a single integer on a new line which is the number of themes that have more than one book associated with them.## sample

1
4
PrideAndPrejudice Romance
Emma Romance
ToKillAMockingbird Classic
GoneWithTheWind Classic
2

</p>