How much?

No attempts yetTime limit1sMemory limit128 MB

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. (1s1000001 \le s \le 100\,000)

The second line contains the number nn of distinct options Haebin wants to buy. (0n10000 \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. (1q1001 \le q \le 100, 1p100001 \le p \le 10\,000)

Output

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