#include<iostream>#include<cmath>#include<cstring>#include<cstdio>#define eps 1e-8#define min(x,y) ((x)<(y)?(x):(y))using namespace std;double w,h,a,b;struct g{double x,y;int t;}s,e;g operator +(g a,g b){g d=a;d.x=a.x+b.x;d.y=a.y+b.y;return d;}struct gg{g a,b;}p[5];bool check(g d){double lx,ly,rx,ry,nowa,nowb;if(d.t==1){nowa=a;nowb=b;}else{nowa=b;nowb=a;}lx=d.x-0.5*nowa;ly=d.y-0.5*nowb;rx=d.x+0.5*nowa;ry=d.y+0.5*nowb;if(lx>-eps&&rx<w+eps&&ly>-eps&&ry<h+eps)return true;else return false;}double dis(g a, g b){return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}bool check1(g s,double XL,double XR,double YL,double YR){if(s.x>XL-eps&&s.x<XR+eps&&s.y>YL-eps&&s.y<YR+eps)return true;else return false;}double gao(gg a,g b,g b1){g c=a.a,d=a.b;g e,f;while(dis(c,d)>eps){e=c+d;e.x*=0.5;e.y*=0.5;f=c+e;f.x*=0.5;f.y*=0.5;double l1,l2,l3,l4;l1=dis(e,b);l2=dis(e,b1);l3=dis(f,b);l4=dis(f,b1);if(dis(e,b)+dis(e,b1)>dis(f,b)+dis(f,b1))d=e;elsec=f;}return dis(e,b)+dis(e,b1);}int main(){int flag;double ans,c,XL,XR,YL,YR;while(scanf("%lf%lf%lf%lf",&w,&h,&a,&b)!=EOF){flag=1;scanf("%lf%lf%d%lf%lf%d",&s.x,&s.y,&s.t,&e.x,&e.y,&e.t);if(!check(s)||!check(e))flag=0;if(!flag){printf("-1n");continue;}if(s.t==e.t){ans=dis(s,e);printf("%.3lfn",ans);continue;}c=sqrt(a*a+b*b);if(c>w+eps||c>h+eps)flag=0;if(!flag){printf("-1n");continue;}c*=0.5;XL=c;XR=w-c;YL=c;YR=h-c;if(check1(s,XL,XR,YL,YR)&&check1(e,XL,XR,YL,YR))ans=dis(s,e);else{ans=1000000000;p[0].a.x=c;p[0].a.y=c;p[0].b.x=c;p[0].b.y=h-c;p[1].a.x=c;p[1].a.y=h-c;p[1].b.x=w-c;p[1].b.y=h-c;p[2].a.x=w-c;p[2].a.y=h-c;p[2].b.x=w-c;p[2].b.y=c;p[3].a.x=c;p[3].a.y=c;p[3].b.x=w-c;p[3].b.y=c;ans=gao(p[0],s,e);ans=min(ans,gao(p[1],s,e));ans=min(ans,gao(p[2],s,e));ans=min(ans,gao(p[3],s,e));}printf("%.3lfn",ans+eps);}}


