// Arup Guha
// 9/7/2013
// Solution to UCF JV Practice Problem B: The Kissing Circles

import java.util.*;

public class b {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Go through each case.
		for (int loop=0; loop<numCases; loop++) {

			int radius = stdin.nextInt();
			int numCircles = stdin.nextInt();

			// Get the area and find the radius of the little circle.
			double totalArea = Math.PI*radius*radius;
			double theta = Math.PI/numCircles;

			// This works by creating the right triangle formed by connecting the
			// center of the little and big circles (hypotenuse) with the corresponding
			// tangent line to the little circle.
			double littleR = radius*Math.sin(theta)/(1+Math.sin(theta));
			double circleArea = numCircles*Math.PI*littleR*littleR;

			// Calculate the area of one of the trapezoids formed by the tangent lines
			// to a little circle from the center of the big circle and the radii to those
			// points. The sector is the corresponding sector of a little circle.
			double trapArea = littleR*(radius-littleR)*Math.cos(theta);
			double sectorArea = littleR*littleR*(Math.PI-2*theta)/2;

			// Now, we can calculate both pretty easily.
			double innerArea = numCircles*(trapArea-sectorArea);
			double outerArea = totalArea - innerArea - circleArea;
			System.out.printf("%.4f %.4f\n", innerArea, outerArea);
		}
	}
}