This page is still under construction.

Parts of this page are still being built. What you see may change.

Pulse Nova

Time limit20sMemory limit256 MB

Summary
Place a circle of radius R so that the total length of the given lines' segments inside the circle is maximized.
Level

Hard8 of 10

Topics
Geometry, Brute force
Solved
No attempts yet

Statement

Mr.Panda is playing Watcher of Samsara, a tower defense game. At the start of the game, every player can freely pick their first hero from a hero pool that the game system generates at random. Mr.Panda always picks Leshrac, because of the character's ultimate skill, Pulse Nova.

Pulse Nova sends out a wave of damaging energy around Leshrac once per second, hitting every nearby enemy unit. This skill gave Mr.Panda an idea for a geometry problem.

There are nn straight lines on the 2D plane. The ii-th line passes through two integer points PiP_i and QiQ_i. Place a circle with radius exactly RR on the plane. For each given line, a segment of that line may lie inside the circle. Find a position for the circle that maximizes the total length of all these segments inside the circle.

Input

The first line contains TT (1≤T≤1001 \le T \le 100), the number of test cases. Each test case follows.

The first line of each test case contains two integers nn (1≤n≤501 \le n \le 50) and RR (1≤R≤30001 \le R \le 3000), the number of lines and the radius of the circle.

The next nn lines each contain four integers. On the ii-th of these lines, the first two integers are the coordinates of PiP_i, and the last two are the coordinates of QiQ_i. Pi≠QiP_i \ne Q_i, and the absolute value of every coordinate is at most 1000.

The sum of nn over all test cases is at most 100.

Output

For each test case, print one line in the form Case #x: y, where xx is the test case number starting from 1, and yy is the maximum total length inside the circle. An answer is correct if its absolute or relative error is within 10−610^{-6}.

Hint

In the first sample, placing the center at (1,1)(1, 1) gives a total length of 8 inside the circle.

In the second sample, placing the center at (0,1)(0, 1) gives a total length of 12+8212 + 8\sqrt{2} inside the circle.

Examples1

  1. Example 1

    Input
    3
    2 2
    1 1 1 2
    1 1 2 1
    4 3
    0 0 0 1
    2 0 0 1
    0 0 1 0
    0 2 1 2
    5 4
    1 3 -2 3
    0 0 4 0
    0 1 -1 2
    -3 1 2 -1
    1 3 2 -3
    
    Expected output
    Case #1: 8.0000000000
    Case #2: 23.3137084990
    Case #3: 38.0402955628