Sail is on Treasure Island. He foresees that $$$n$$$ events will occur on the island, and he will leave after all events have finished. Specifically, there are the following three types of events:
He wants to know whether he can leave the island safely, and if so, what is the maximum amount of money he can have left when leaving.
The first line contains a positive integer $$$T$$$ ($$$1 \le T \le 10^4$$$), indicating the number of test cases.
For each test case, the first line contains two positive integers $$$n$$$ ($$$1 \le n \le 2 \times 10^5$$$) and $$$k$$$ ($$$1 \le k \le 10^6$$$), where $$$n$$$ is the total number of events, and $$$k$$$ is the amount of money obtained from exchanging coins or the damage value of a bullet.
The next $$$n$$$ lines each contain two positive integers $$$o$$$ ($$$o \in \{1, 2, 3\}$$$) and $$$x$$$ ($$$1 \le x \le 10^6$$$), representing an event.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \times 10^5$$$.
For each test case, if Sail cannot leave safely, output $$$-1$$$; otherwise, output the maximum amount of money that can remain.
54 31 23 52 33 34 31 22 23 53 14 31 22 23 53 34 31 23 52 23 34 31 21 33 43 9
010-10
For the second test case, Sail does the following in order:
In the end, Sail leaves with $$$1$$$ yuan.
For the fourth test case, Sail does the following in order:
No matter how he performs the exchanges, Sail cannot leave safely, so you should output $$$-1$$$.