#include using namespace std; #define MAXN 200005 #define MAXM 800005 #define real long double real w[MAXM],d[MAXN]; int T,n,m,i,j,u,v,ax,bx,ay,by,lx[205],rx[205],ly[205],ry[205],N,M,x[405],y[405],a[405][405],b[405][405],h[MAXN],ne[MAXM],p[MAXM]; void add(int x,int y,real z) { p[++m]=y; ne[m]=h[x]; w[m]=z; h[x]=m; p[++m]=x; ne[m]=h[y]; w[m]=z; h[y]=m; } struct node { int i; real d; bool operator<(const node& y)const { return d>y.d; } }t,t1; priority_queue H; int main() { scanf("%d",&T); while(T--) { scanf("%d",&n); N=M=0; for(i=1;i<=n;i++) { scanf("%d%d%d%d",lx+i,ly+i,rx+i,ry+i); x[++N]=lx[i]; x[++N]=rx[i]; y[++M]=ly[i]; y[++M]=ry[i]; } scanf("%d%d%d%d",&ax,&ay,&bx,&by); x[++N]=ax; x[++N]=bx; y[++M]=ay; y[++M]=by; sort(x+1,x+N+1); sort(y+1,y+M+1); N=unique(x+1,x+N+1)-x-1; M=unique(y+1,y+M+1)-y-1; ax=lower_bound(x+1,x+N+1,ax)-x; bx=lower_bound(x+1,x+N+1,bx)-x; ay=lower_bound(y+1,y+M+1,ay)-y; by=lower_bound(y+1,y+M+1,by)-y; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); for(i=1;i<=n;i++) { lx[i]=lower_bound(x+1,x+N+1,lx[i])-x; rx[i]=lower_bound(x+1,x+N+1,rx[i])-x; ly[i]=lower_bound(y+1,y+M+1,ly[i])-y; ry[i]=lower_bound(y+1,y+M+1,ry[i])-y; a[lx[i]][ly[i]]++; a[rx[i]][ly[i]]--; a[lx[i]][ry[i]+1]--; a[rx[i]][ry[i]+1]++; b[lx[i]][ly[i]]++; b[rx[i]+1][ly[i]]--; b[lx[i]][ry[i]]--; b[rx[i]+1][ry[i]]++; } n=N*M; m=0; fill(h+1,h+n+1,0); fill(d+1,d+n+1,1e15); for(i=1;it.d+w[i]) { t1.d=d[p[i]]=t.d+w[i]; t1.i=p[i]; H.push(t1); } } printf("%.5lf\n",(double)d[v]); } return 0; }