Like many others, Mimi has spent the last month practicing social distancing. As part of her efforts, she has started shopping entirely online. She's found that online shopping offers a lot of advantages. In particular, you can easily look at many different websites in order to find the best price for an item.
However, others have also started shopping online, which means that stores are running out of inventory. As a result, Mimi often has to order from multiple websites in order to get all the items that she wants.
Mimi has a number of items that she has to buy. Can you help Mimi determine the minimum amount of money that she needs to spend to buy all the items?
Input Specification
The first line begins with a single integer
Each test case begins with one integer
The next line contains an integer
It is guaranteed that, unlike the real world, the total quantity of each item available in stores is greater than or equal to the quantity that Mimi would like to buy.
Output Specification
For each test case, print a single integer: the minimum amount that Mimi needs to spend to buy all the items that she wants.
Sample Input
1
2
2
toiletpaper 1 50
catnip 2 25
1
toiletpaper 100 1
2
toiletpaper 51
catnip 10
Sample Output
170
Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org
Comments