|
Uh oh, the weather forecast predicts that a rainstorm will soon break out over |
|
the infinite, 1-dimensional number line you call home! |
|
|
|
The forecast is remarkably precise. In fact, it's known that exactly **N** |
|
raindrops will fall, with the **i**th drop striking the number line at |
|
position **Xi** exactly **Ki** seconds after the start of the storm. No two |
|
drops will strike the number line at exactly the same position and time. |
|
|
|
You'd like to stop as many of the drops as possible, but you don't exactly |
|
have an umbrella... so your boomerang will have to do. Your plan is as |
|
follows: |
|
|
|
1. Stand at some (possibly non-integral) position A on the number line, and choose some other position B (A ≠ B). |
|
2. At some point in time, throw your boomerang from A to B. This point in time can be arbitrarily long before or after the start of the storm (the storm won't start for a while, so you have time to prepare). The boomerang will travel along your chosen line segment at a constant speed of S units per second. |
|
3. Make your boomerang spin in place at position B for some non-negative amount of time (which can be arbitrarily large). |
|
4. Have your boomerang travel back along the line segment from B to A at the same speed, and catch it as soon as it gets back to position A. |
|
|
|
During the inclusive time interval from when you throw the boomerang to when |
|
you catch it again, if the boomerang is ever at exactly the same position as a |
|
raindrop at exactly the time that it strikes the number line, it will |
|
intercept it... just like an umbrella! What's the maximum number of raindrops |
|
you can intercept in this way with a single throw? |
|
|
|
### Input |
|
|
|
Input begins with an integer **T**, the number of rainstorms. For each |
|
rainstorm, there is first a line containing the space-separated integers **N** |
|
and **S**. Then, **N** lines follow, the **i**th of which contains the space- |
|
separated integers **Xi** and **Ki**. |
|
|
|
### Output |
|
|
|
For the **i**th rainstorm, print a line containing "Case #**i**: " followed by |
|
the maximum number of raindrops you can stop. |
|
|
|
### Constraints |
|
|
|
1 ≤ **T** ≤ 50 |
|
1 ≤ **N** ≤ 100,000 |
|
1 ≤ **S** ≤ 1,000,000,000 |
|
0 ≤ **Xi**, **Ki** ≤ 1,000,000,000 |
|
|
|
### Explanation of Sample |
|
|
|
In the first rainstorm, one solution is to stand at X = 99 and let your |
|
boomerang spin at X = 100 until it intercepts all three raindrops that will |
|
fall at that position. In the second rainstorm, one solution is to stand at X |
|
= 50 and throw your boomerang towards X = 100 as soon as the first raindrop |
|
hits it. If you recall your boomerang as soon as it reaches X = 100, it will |
|
hit the second raindrop and be back just in time to hit the third. |
|
|
|
|