Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Simple Pyramid

Limits: 1s, 256 MB

You are given a pyramid with a polygonal base. Can you calculate the volume and surface area of the slanted surface (inclined surface or total surface excluding the surface of the base) of the pyramid? Formally speaking, let’s consider the apex of the pyramid at points (0, 0, H) in 3D space. The base of the pyramid is a simple polygon with N vertices located on the XY plane of 3D space.

Input

The first line of the input contains an integer T (0 < T < 101) representing the number of test cases. Each test case starts with two integers N and H which denote the number of vertices on the base and the height of the pyramid respectively (3 ≤ N, H ≤ 100). Next N lines, each contains two integers x, y (-100 ≤ x, y ≤ 100). Vertices of the base will be given in counter-clockwise order.

Output

For each case print the volume and surface area of the slanted surface of the pyramid separated by space. Errors less than 10-6 will be ignored.

Samples

InputOutput
2
4 5
0 0
1 0
1 1
0 1
3 3
-2 -2
2 -2
0 3

1.666666667 10.099019514
10.000000000 24.444790491

Authors
Discussion
Submit

Login to submit