#include<stdio.h> #include<math.h> int main() { int i,j,k,n,m,t; double a[220]; a[0]=0; for(i=1;i<=210;i++) a[i]=a[i-1]+sqrt(1.0*i*i+1.0*(i-1)*(i-1))+sqrt(1.0*i*i*2); int x1,y1,x2,y2; scanf("%d",&t); while(t--) { scanf("%d%d%d%d",&x1,&y1,&x2,&y2); double r,y; if(x1==0&&y1==0) r=0; else { m=x1+y1-1; r=a[m]+sqrt(1.0*m*m+1.0*(m+1)*(m+1))+sqrt(1.0*x1*x1+1.0*(m+1-y1)*(m+1-y1)); } if(x2==0&&y2==0) y=0; else { m=x2+y2-1; y=a[m]+sqrt(1.0*m*m+1.0*(m+1)*(m+1))+sqrt(1.0*x2*x2+1.0*(m+1-y2)*(m+1-y2)); } printf("%.3f ",fabs(y-r)); } return 0; }