407172: GYM102697 143 Zoom Meeting

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

143. Zoom Meetingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
This problem is worth 35 points.

You're attending an international Zoom call during the Coronavirus quarantine, where the attendees represent many different countries. The zoom call is really long, and to pass the time, you tally how many people are from each country.

Given the list of people and their countries, print the countries, and how many meeting attendees are from each country. Sort the countries first by their number of attendees, and if two countries have an equal number of attendees, sort them alphabetically by the name of the country.

Input

The first line of input contains a single positive integer $$$n$$$: the number of meeting attendees.

The next $$$n$$$ lines each contain a single country name $$$c$$$.

Output

If there are less than five lines of input, output $$$n$$$ lines: each country, and it's number of meeting attendees, separated by a space.

Otherwise, output 5 lines: each of the top 5 countries using the sorting method described above, and it's number of meeting attendees, separated by a space.

ExamplesInput
11
USA
Sweden
Argentina
Cameroon
Egypt
Australia
England
France
Russia
Mongolia
India
Output
Argentina 1
Australia 1
Cameroon 1
Egypt 1
England 1
Input
4
USA
USA
Mexico
Mexico
Output
Mexico 2
USA 2
Input
9
USA
Germany
Brazil
China
USA
China
China
USA
USA
Output
USA 4
China 3
Brazil 1
Germany 1

加入题单

算法标签: