#K81217. Stamp Collection Summary

    ID: 35705 Type: Default 1000ms 256MiB

Stamp Collection Summary

Stamp Collection Summary

You are given a collection of stamps where each stamp is represented by a string containing a stamp name and the country of origin, separated by the last space in the string.

Your task is to compute a summary report that maps each country to the number of unique stamp names from that country. Formally, for each country with a set of stamp names \(S\), you should output the pair \( (\text{country}, |S|) \), where \(|S|\) denotes the number of unique stamp names.

The output should be a JSON-like dictionary with the country names as keys and their corresponding counts as values. Note: The keys in your output should be sorted in alphabetical order.

inputFormat

The first line contains an integer \(n\) representing the number of stamps. The following \(n\) lines each contain a string that describes one stamp. Each string consists of the stamp name and the country, separated by the last space character.

outputFormat

Output a JSON-like dictionary (object) where the keys are country names (in alphabetical order) and the values are the counts of unique stamp names from that country.

For example, an output might look like:

{"China": 1, "India": 1, "Japan": 2, "USA": 1}
## sample
6
BlueMoon USA
RedSun Japan
BlueMoon USA
Dragon Japan
Phoenix China
Lotus India
{"China": 1, "India": 1, "Japan": 2, "USA": 1}