#C9132. Taco Shopping List Cost Calculator

    ID: 53192 Type: Default 1000ms 256MiB

Taco Shopping List Cost Calculator

Taco Shopping List Cost Calculator

This problem involves processing multiple users' shopping lists. Each shopping list contains a number of items, each with a price and a category. Your task is to compute the total spending for each category in a case-insensitive manner, and then output the results in alphabetical order. Specifically, for each user's shopping list, you must return an array where the first element is the number of distinct categories, followed by strings formatted as category total.

The calculation for the total is given by the formula \( Total = \sum_{i=1}^{n} price_i \), where \( n \) is the number of items in that category.

inputFormat

The input is read from standard input (stdin). The first line contains an integer \(U\), representing the number of users. For each user, the first line contains an integer \(N\) indicating the number of items in the shopping list, followed by \(N\) lines. Each of these lines consists of an integer price and a string category (which may include both uppercase and lowercase letters). Note that categories are processed in a case-insensitive manner.

outputFormat

Output the results to standard output (stdout) as a JSON array. Each element in the array corresponds to a user's processed shopping list, which is itself an array. The first element of each inner array is the number of distinct categories, and the subsequent elements are strings formatted as category total (with category names in lowercase) in alphabetical order.

## sample
2
3
100 food
250 Electronics
50 Food
2
500 clothes
300 CLOTHES
[[2, "electronics 250", "food 150"], [1, "clothes 800"]]