You receive raw sales records as comma-separated "region,amount" pairs.
Aggregate total revenue per region.
Input Format:
Line 1: n (number of records)
Lines 2 to n+1: region,amount (amount is an integer)
Output Format:
One line per region: "<region> <total>"
Sorted by total descending; ties broken by region ascending.