#C2387. Most Frequent Fruit Calories

    ID: 45697 Type: Default 1000ms 256MiB

Most Frequent Fruit Calories

Most Frequent Fruit Calories

You are given a list of records representing fruits and the calories consumed in a single occurrence. Your task is to determine the fruit that occurs most frequently in the list and compute the total calorie count for that fruit.

Formally, let \( n \) be the number of records. Each record is a pair \((s, c)\), where \( s \) is the fruit name and \( c \) is the number of calories. You need to find the fruit \( f \) which appears the most times and calculate \( T \), the sum of all calories for fruit \( f \).

If two or more fruits have the same maximum frequency, output the one that appears first in the input order.

Example:

Input:
5
Apple 120
Banana 150
Apple 130
Cherry 50
Apple 140

Output: Apple 390

</p>

The above example shows that "Apple" appears 3 times and the total calories for Apple is \(120+130+140 = 390\).

inputFormat

The first line of input contains an integer \( n \) denoting the number of records. Each of the following \( n \) lines contains a fruit name (a string without spaces) and an integer representing the calories, separated by a space.

outputFormat

Output a single line containing the fruit name with the highest frequency followed by a space and the total calories for that fruit.

## sample
5
Apple 120
Banana 150
Apple 130
Cherry 50
Apple 140
Apple 390