#K76617. Unique Names Counter

    ID: 34683 Type: Default 1000ms 256MiB

Unique Names Counter

Unique Names Counter

In this problem, you are given a list of full names where each name is formatted as FirstName LastName. Your task is to count how many unique first names and unique last names appear in the list. The problem can be formulated as follows: given a list of names, let \(F\) be the set of all first names and \(L\) be the set of all last names. You need to output the sizes of \(F\) and \(L\).

For example, for the names "John Doe", "Jane Doe", "Emily Smith", "Jane Smith", "John Smith", the unique first names are {John, Jane, Emily} (3 unique names), and the unique last names are {Doe, Smith} (2 unique names).

Note: Each full name consists of exactly two parts separated by a space.

inputFormat

The first line contains an integer (N) representing the number of names. Each of the following (N) lines contains a full name in the format "FirstName LastName".

outputFormat

Output two integers separated by a space: the number of unique first names and the number of unique last names.## sample

1
John Doe
1 1