// Arup Guha
// 12/16/2016
// Solution to 2016 Online HS Problem: Square Circle

import java.util.*;

public class squircle {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process each case.
		for (int loop=1; loop<=numCases; loop++) {

			// Get dimensions.
			int r = stdin.nextInt();
			int s = stdin.nextInt();

			// Count main column once - the # in the sqrt represents the y coordinate of the corner of the first
			// square when the square is centered at (0, 0). We double it since we can go to negative of that coordinate.
			int res = (int)( (2*Math.sqrt(r*r-s*s/4.0)+1e-9)/s );

			// Next starting x coordinate for column 2, just right of center.
			double x = 3.0*s/2;
			while (x < r) {

				// What we can add on this column.
				int add = (int)( (2*Math.sqrt(r*r-x*x)+1e-9)/s );

				// Ran out of room, get out!
				if (add == 0) break;

				// Need to add for this column and symmetric column on left.
				res += 2*add;

				// Go to next x coordinate.
				x += s;
			}

			// Now, multiply in the area of each square.
			res *= (s*s);

			// Print out the result.
			System.out.println("Measure #"+loop+": "+res);
		}

	}
}