
Figure 1. An example of a fence shape.
Mr. A wants to live in a house surrounded by a fence of flowering trees, so he asked a design firm to draw up the plans. He liked the design, but wished the yard were a little larger. The fence in the design has no parts that cave inward: it is a convex shape, and because it should look good when seen from the hill behind the village, its exact form must be preserved. That is, the ratios between the side lengths and the angles between adjacent sides may not change; the whole fence may only be scaled up or down by the same factor.
The construction cost of the fence is proportional to its total length. Changing the area of the land enclosed by the fence (adjusting only the size while keeping the shape) also changes the length of the fence, and therefore the price of the contract. Given the desired area of land, determine how long the fence must be to enclose that area while keeping the same shape.
Input is given through standard input. The first line contains the number of test cases T (1≤T≤20).
Each test case is given as follows. The first line contains the area x of the land to be enclosed by the fence. The second line contains the number N (3≤N≤10000) of corners at which the fence changes direction. Each of the next N lines contains the x and y coordinates of one corner, separated by a space, listed in either clockwise or counterclockwise order.
Coordinates and areas are real numbers. Lengths are measured in meters and areas in square meters (m²). The given fence shape is always convex.
For each test case, print on its own line the total length of the fence when the given shape is scaled up or down (keeping it similar) so that the enclosed area is exactly x. Print the length rounded to four digits after the decimal point, always in fixed-point form with exactly four decimals (for example, 8.0000).