Fly Swatter (Small)

Compute the probability that a randomly placed fly disk touches a circular ring crossed by a grid of cylindrical strings, and print it to six decimals.

Hard8GeometryMathProbabilityImplementationNo attempts yetTime limit5sMemory limit512 MB

Problem

What are your chances of hitting a fly with a tennis racquet?

Ignore the racquet's handle. Assume the racquet is a perfect ring with outer radius RR and thickness tt, so the inner radius of the ring is RtR - t.

The inside of the ring is covered with horizontal and vertical strings. Each string is a cylinder of radius rr and lies along a chord of the ring, a straight line joining two points of the circle. Neighbouring strings have a gap of length gg between them. The strings are symmetric about the center of the racquet: one horizontal string and one vertical string have their center lines through the center of the ring. In both directions, a string's center line sits at distance k(2r+g)k(2r+g) from the center for every integer kk with k(2r+g)<Rk(2r+g) < R.

The fly is a sphere of radius ff. The racquet moves along a straight line perpendicular to the plane of the ring. The fly's center is inside the outer radius of the racquet and is uniformly distributed over that disk. Any overlap between the fly and the racquet (the ring or a string) counts as a hit.

Input

The first line contains an integer NN, the number of test cases.

Each of the next NN lines contains ff, RR, tt, rr and gg separated by exactly one space. Each number has at most 6 digits after the decimal point.

Limits

  • ff, RR, tt, rr and gg are positive and at most 1000010000.
  • t<Rt < R
  • f<Rf < R
  • r<Rr < R
  • 1N301 \le N \le 30
  • The total number of strings is at most 6060, so at most 3030 in each direction.

Output

Print NN lines. Line kk has the form Case #k: P, where kk is the test case number and PP is the probability that some part of the racquet touches the fly. Print PP rounded to exactly 6 digits after the decimal point.