#K34277. Count Unique Departments

    ID: 25274 Type: Default 1000ms 256MiB

Count Unique Departments

Count Unique Departments

In this problem, you are given several test cases, where each test case contains a list of employees with their IDs and department names. Your task is to determine the number of unique departments in each test case. In other words, for each test case, you need to compute the cardinality of the set (S) where (S) is defined as the set of distinct department names in that test case.

For example, if a test case contains the entries: ( (E001, HR), (E002, Finance), (E003, HR) ), the answer will be (2) because there are two distinct departments: HR and Finance.

inputFormat

The input starts with an integer (T) representing the number of test cases. Each test case begins with an integer (n) on a new line (the number of employees), followed by (n) lines. Each line contains an employee ID and the department name separated by a space.

outputFormat

For each test case, output a single integer that represents the number of unique departments. Each result should be printed on a new line.## sample

1
3
E001 HR
E002 Finance
E003 HR
2

</p>