## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

## [Solution] Count the Trains Codeforces Solution

G. Count the Trains
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

There are $n$ of independent carriages on the rails. The carriages are numbered from left to right from $1$ to $n$. The carriages are not connected to each other. The carriages move to the left, so that the carriage with number $1$ moves ahead of all of them.

The $i$-th carriage has its own engine, which can accelerate the carriage to ${a}_{i}$ km/h, but the carriage cannot go faster than the carriage in front of it. See example for explanation.

All carriages start moving to the left at the same time, and they naturally form trains. We will call trains — consecutive moving carriages having the same speed.

For example, we have $n=5$ carriages and array $a=\left[10,13,5,2,6\right]$. Then the final speeds of the carriages will be $\left[10,10,5,2,2\right]$. Respectively, $3$ of the train will be formed.

There are also messages saying that some engine has been corrupted:

• message "k d" means that the speed of the $k$-th carriage has decreased by $d$ (that is, there has been a change in the maximum speed of the carriage ${a}_{k}={a}_{k}-d$).

Messages arrive sequentially, the processing of the next message takes into account the changes from all previous messages.

After each message determine the number of formed trains.

Input

The first line of input data contains a single integer $t$ ($1\le t\le {10}^{4}$) —the number of input test cases.

This is followed by descriptions of the test cases.

The first line of each test case is empty.

The second line of the test case contains two integers $n$ and $m$ ($1\le n,m\le {10}^{5}$) —the number of carriages and the number of messages to slow down the carriage, respectively.

The third line contains $n$ integers: ${a}_{1},{a}_{2},\dots ,{a}_{n}$ ($0\le {a}_{i}\le {10}^{9}$) — the number ${a}_{i}$ means that the carriage with number $i$ can reach a speed of ${a}_{i}$ km/h.

The next $m$ lines contain two integers ${k}_{j}$ and ${d}_{j}$ ($1\le {k}_{j}\le n$$0\le {d}_{j}\le {a}_{{k}_{j}}$) —this is the message that the speed of the carriage with number ${k}_{j}$ has decreased by ${d}_{j}$. In other words, there has been a change in its maximum speed ${a}_{{k}_{j}}={a}_{{k}_{j}}-{d}_{j}$. Note that at any time the speed of each carriage is non-negative. In other words, ${a}_{i}\ge {s}_{i}$, where ${s}_{i}$ —is the sum of such ${d}_{j}$ that ${k}_{j}=i$.

It is guaranteed that the sum of $n$ over all test cases does not exceed ${10}^{5}$. Similarly, it is guaranteed that the sum of $m$ over all test cases does not exceed ${10}^{5}$.

Output

Print $t$ lines. On each line print the answer for the corresponding test case.

For each test case print $m$ numbers: the number of trains formed after each message.