How much?
Time limit1sMemory limit128 MB
Add the base car price to each option's quantity times unit price for every test case.
- Level
Easy1 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Problem
Haebin saved up money from odd jobs while going to school and now wants to buy a car. A car can come with several options, but Haebin cannot add or multiply, so he asked his friend Taewan for help. Taewan cannot add or multiply either.
Compute for them how much the car costs once every option they want is included.
Input
The first line contains the number of test cases.
The first line of each test case contains the price of the car itself. ()
The second line contains the number of distinct options Haebin wants to buy. ()
Each of the next lines contains and . Here is how many units of that option Haebin buys and is the price of one unit of that option. (, )
Output
For each test case, print the final price Haebin pays for the car, one per line.