Ninjutsu (Small)

Cut the rope to any length up to R so the counterclockwise swing bends around the maximum number of point targets.

Hard8GeometryBacktrackingNo attempts yetTime limit5sMemory limit512 MB

Problem

Ninjutsu is the martial art of the Japanese assassins called ninja. You are a beginner, and your first task is to master the grappling hook.

A grappling hook is a hook tied to a very strong and very thin rope. You use it by throwing the hook at a target and hoping that it catches.

This time it caught. You are hooked onto a target at (0,0)(0, 0). The rope extends to the left and you hold its far end. When you jump, you start swinging counterclockwise around that target. The other targets sit to the right of and above (0,0)(0, 0), at (xi,yi)(x_i, y_i) with xi0x_i \ge 0 and yi0y_i \ge 0. When an interior point of the rope, that is a point which is not either end, touches one or more targets, the rope bends around the target closest to its moving end. Ignore your starting velocity. You are a ninja, so it is fast enough that you keep bending around targets until you are spinning around a single one.

The rope has length RR right now, but before you start swinging you may cut it down to any shorter length rr. The value of rr does not have to be an integer. You then start at (r,0)(-r, 0) and swing counterclockwise toward (0,r)(0, -r).

What is the largest number of bends you can put into the rope in one swing? A bend happens when the rope touches a target and then rotates a nonzero number of degrees around that target. Away from the bends the rope always stays perfectly straight, which is again possible because you are a ninja. You may wrap around the same target several times, and the target at (0,0)(0, 0) is a bending point just like every other target.

The picture above has 6 targets.

  • (0,0)(0, 0)
  • (3,1)(3, 1)
  • (12,4)(12, 4)
  • (14,5)(14, 5)
  • (13,7)(13, 7)
  • (7,10)(7, 10)

The rope has length 2424. If you do not cut it, you bend around (12,4)(12, 4), then around (14,5)(14, 5), then around (13,7)(13, 7), and you end up orbiting (7,10)(7, 10) with about 0.17050.1705 units of rope left. That is 4 bends in total. You do touch (3,1)(3, 1), but it produces no bend because it is collinear with (0,0)(0, 0) and (12,4)(12, 4).

If instead you cut 0.180.18 units off the rope, you can no longer reach (7,10)(7, 10), so you follow the path

(0, 0)--(12, 4)--(14, 5)--(13, 7)--(12, 4)--(14, 5)

and end up orbiting (14,5)(14, 5) with about 1.30041.3004 units of rope left. That path has 5 bends in total, and it is optimal.

Input

The first line has TT, the number of test cases. The first line of each test case has two integers NN and RR. The next NN lines each have the coordinates xix_i and yiy_i of a target, starting with the target at (0,0)(0, 0).

Limits

  • 1T1001 \le T \le 100
  • All target coordinates are integers.
  • All targets are at different positions.
  • The first target listed is at (0,0)(0, 0).
  • At least one value of rr that gives an optimal answer has the property that a rope of length r0.999999r - 0.999999 gives the same solution, meaning the same sequence of bends.
  • 1N101 \le N \le 10
  • 1R1,0001 \le R \le 1{,}000
  • 0xi1,0000 \le x_i \le 1{,}000
  • 0yi1,0000 \le y_i \le 1{,}000

Output

For each test case, print one line of the form "Case #CC: kk", where CC is the 1-based test case number and kk is the largest number of bends that can be made in the rope in one swing.