This page is still under construction.

Parts of this page are still being built. What you see may change.

How much?

Time limit1sMemory limit128 MB

Summary
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 ss of the car itself. (1≤s≤100 0001 \le s \le 100\,000)

The second line contains the number nn of distinct options Haebin wants to buy. (0≤n≤1 0000 \le n \le 1\,000)

Each of the next nn lines contains qq and pp. Here qq is how many units of that option Haebin buys and pp is the price of one unit of that option. (1≤q≤1001 \le q \le 100, 1≤p≤10 0001 \le p \le 10\,000)

Output

For each test case, print the final price Haebin pays for the car, one per line.

Examples1

  1. Example 1

    Input
    2
    10000
    2
    1 2000
    3 400
    50000
    0
    
    Expected output
    13200
    50000