Fences

Given the circumference of a circle and the side lengths of an inscribed-tangent polygon whose vertices are equidistant from the circle, find the area between them.

Medium7GeometryMathImplementationBrute forceNo attempts yetTime limit3sMemory limit512 MB

Problem

Your friend Donald has a villa surrounded by two tiers of fences, and he wants to know the area of the land between them. He can measure the length of any part of a fence, but he does not know how to compute the area. Watson, another friend of Donald, decided that the fences were built by someone who knows computational geometry, because the following three facts are no coincidence.

  • The land inside the outer tier is a perfect circle CC. Let BB be the set of points on the boundary of CC.
  • The land inside the inner tier is a non-self-intersecting polygon PP with nn vertices. That is, two edges that share no vertex never intersect. Let VV be the set of vertices of PP.
  • Every vertex of PP has the same minimum distance to CC. In other words, for any two distinct vertices (xu,yu),(xv,yv)V(x_u, y_u), (x_v, y_v) \in V,

min(x,y)B(xxu)2+(yyu)2=min(x,y)B(xxv)2+(yyv)2\min_{(x,y) \in B} \sqrt{(x - x_u)^2 + (y - y_u)^2} = \min_{(x,y) \in B} \sqrt{(x - x_v)^2 + (y - y_v)^2}

You are given the total length cc of the outer tier and the lengths 1,,n\ell_1, \dots, \ell_n of the edges of PP. Donald can measure all of these himself. Compute the area of the land between the two tiers.

Input

The first line contains the number of test cases TT. Each test case consists of two lines. The first line contains two numbers cc and nn separated by a space. cc is the total length of the outer tier, that is, the perimeter of CC, and nn is the number of vertices of PP. The second line contains the edge lengths 1,,n\ell_1, \dots, \ell_n of PP.

  • 1T1001 \le T \le 100
  • 3n103 \le n \le 10
  • 10c100010 \le c \le 1000
  • 1,,n\ell_1, \dots, \ell_n are positive integers.
  • A polygon PP satisfying the conditions above always exists for the given lengths, and PP lies inside the circle CC.

Output

For each test case, print the area of the land between the two tiers on its own line. Round the area to six digits after the decimal point and print all six digits, including trailing zeros.