// Arup Guha
// 3/28/2020
// Solution to 2020 MAPS Problem D: Greedy Polygons
// Written in Contest, Commented Later

import java.util.*;

public class greedypolygons {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		
		// Process all cases.
		for (int loop=0; loop<nC; loop++) {
	
			// Get input.
			int n = stdin.nextInt();
			int len = stdin.nextInt();
			int d = stdin.nextInt();
			int numG = stdin.nextInt();
			
			// Sum area all rectangles emanating from sides.
			double rect = len*numG*d*n;
			
			// Sum area arcs...make one circle rad d*numG.
			double circ = Math.PI*Math.pow(numG*d,2);
			
			// apothem
			double a = len*Math.tan(Math.PI/2-Math.PI/n)/2;
			
			// orig poly area
			double poly = a*n*len/2;
			
			// Ta da!
			System.out.println(rect+circ+poly);
		}
	}
}