/*
* 解题思路:
* 题意不难理解、一直求内接圆半径、知道半径长度小于0.000001为止
*/
#include <math.h>
#include <stdio.h>
int main( )
{
int t;
double x,y,r,sum;
const double pi = 4.0 * atan( 1.0 );
scanf("%d",&t);
while( t-- )
{
scanf("%lf%lf",&x,&y);
sum = 0;
r = tan( atan( y/x*2 ) /2 ) * x/2;
while( r >= 0.000001 )
{
sum += r;
x = x/y*( y-2*r );
y -= 2*r;
r = tan( atan( y/x*2 ) /2 ) * x/2;
}
printf("%13.6lf\n",sum*2*pi);
if( t ) puts("");
}
return 0;
}