K. Kingdom Rush: Vengeance
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Colin is a huge fan of the Kingdom Rush franchise tower defense games. In the latest generation of Kingdom Rush: Vengeance, Colin's favorite tower is the rotten forest, which can continuously inflict damage to all enemies within its control range.

Colin liked this convenient AOE(area-of-effect) damage tower so much that he decided to only use the rotten forest in the game! In order to practice the strategy of arranging towers, Colin modeled the game content and conducted several numerical experiments.

To simplify the problem, Colin assumes that the path of the map is a number axis. Enemies will be generated from some points and move in the positive direction of the number axis at a constant speed of $$$1$$$ unit per second. There are $$$n$$$ rotten forest towers along the path, where the $$$i$$$-th tower controls the range $$$[L_i,R_i]$$$ and will inflict $$$w_i$$$ damage to each enemy within its control range at the end of each second. Note that the ranges controlled by different towers may overlap. In this case, the damage received by enemies in the overlapping area per second is the sum of the damage of all towers controlling this area. For example, assume that there is a tower that controls the range $$$[3,4]$$$ and another tower controls the range $$$[4,5]$$$. If an enemy is generated at the point $$$0.5$$$ at time $$$t=0.5s$$$, then it will receive the damage at the end of the third, fourth, and fifth seconds; and at the end of the fourth second, it will receive the damage from both towers.

In this battle $$$m$$$ enemies are generated at $$$t=0.5s$$$, and the $$$i$$$-th one is generated at the point $$$x_i+0.5$$$ with health $$$h_i$$$. Once the total damage received by an enemy is greater or equal to its health, it will die immediately. Colin wants to know the exact death time of each enemy, or if the existing towers are not enough to kill this enemy.

Input

The first line contains two integers $$$n,m\ (1\le n,m\le 10^5)$$$, representing the number of towers and the number of enemies.

For the following $$$n$$$ lines, each line contains three integers $$$l_i, r_i, w_i\ (1\le l_i\le r_i\le 10^9, 1\le w_i\le 10^4)$$$, representing the range controlled by the $$$i$$$-th rotten forest tower and the damage it could make per second.

For the following $$$m$$$ lines, each line contains two integers $$$x_i, h_i\ (0\le x_i\le 10^9,1\le h_i\le 10^{18})$$$, representingthe $$$i$$$-th enemy is generated at the point $$$x_i+0.5$$$ with health $$$h_i$$$.

Output

Output $$$m$$$ lines, the $$$i$$$-th line contains a single integer, representing the death time of the $$$i$$$-th enemy. If the existing towers are not enough to kill this enemy, output -1.

Example
Input
6 6
1 3 1
2 4 1
3 5 1
4 6 1
5 7 1
6 8 1
0 15
0 17
1 3
1 15
5 7
6 2
Output
6
7
2
6
-1
1