#K1836. Final Bacteria Count

    ID: 24603 Type: Default 1000ms 256MiB

Final Bacteria Count

Final Bacteria Count

You are given a number of test cases. In each test case, you start with an initial number of bacteria n. The bacteria then undergo p phases. In the i-th phase, the bacteria grows for m_i minutes at a growth rate of r_i bacteria per minute. The final bacteria count is calculated using the formula:

$$B = n + \sum_{i=1}^{p} \left(m_i \times r_i\right)$$

Your task is to compute and output the final bacteria count for each test case.

inputFormat

The input is read from standard input (stdin) and has the following format:

  • The first line contains an integer T, the number of test cases.
  • For each test case:
    • The first line contains two integers n and p — the initial number of bacteria and the number of phases.
    • Then follow p lines, each containing two integers m and r which represent the duration (in minutes) and the growth rate for that phase.

outputFormat

For each test case, output the final bacteria count on a new line. The output is written to standard output (stdout).

## sample
1
100 2
5 2
3 1
113

</p>