import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
private static double distance(long X1, long Y1, long X2, long Y2)
{
return Math.
sqrt((X1
-X2
)*(X1
-X2
) + (Y1
-Y2
)*(Y1
-Y2
)); }
{
Scanner in
= new Scanner
(System.
in); long A = in.nextLong();
long B = in.nextLong();
long C = in.nextLong();
long X1 = in.nextLong();
long Y1 = in.nextLong();
long X2 = in.nextLong();
long Y2 = in.nextLong();
long Z2 = in.nextLong();
double S = 10000000;
if (Z2 == 0)
{
S = distance(X1, Y1, X2, Y2);
}
else
{
if (X2 == 0)
{
S
= Math.
min(distance
(X1, Y1,
-Z2, Y2
), distance
(X1, Y1,
-Y2,
-Z2
)); S
= Math.
min(S, distance
(X1, Y1, Y2
- B, B
+ Z2
)); }
if (X2 == A)
{
S
= Math.
min (distance
(X1, Y1, Z2
+ A, Y2
), distance
(X1, Y1, A
+ Y2,
-Z2
)); S
= Math.
min(S, distance
(X1, Y1, A
+ B
- Y2, Z2
+ B
)); }
if (Y2 == 0)
{
S
= Math.
min(S, distance
(X1, Y1, X2,
-Z2
)); S
= Math.
min(S, distance
(X1, Y1,
-Z2,
-X2
)); S
= Math.
min(S, distance
(X1, Y1, A
+ Z2, X2
- A
)); }
if (Y2 == B)
{
S
= Math.
min(S, distance
(X1, Y1, X2, Z2
+ B
)); S
= Math.
min(S, distance
(X1, Y1,
-Z2, X2
+ B
)); S
= Math.
min(S, distance
(X1, Y1, A
+ Z2, B
+ A
- X2
)); }
if ((Y2 != 0) && (Y2 != B) && (X2 != 0) && (X2 != A))
{
S
= Math.
min(C
+ distance
(X1, Y1, X2, Y2
), distance
(X1, Y1, X2,
-Y2
- C
)); S
= Math.
min(S, distance
(X1, Y1, X2,
2*B
- Y2
+ C
)); S
= Math.
min(S, distance
(X1, Y1,
-X2
- C, Y2
)); S
= Math.
min(S, distance
(X1, Y1,
2*A
- X2
+ C, Y2
)); S
= Math.
min(S, distance
(X1, Y1, A
+ B
+ C
- Y2, A
+ B
- X2
)); S
= Math.
min(S, distance
(X1, Y1, A
+ C
+ Y2, X2
- A
)); S
= Math.
min(S, distance
(X1, Y1,
-C
- Y2,
-X2
)); S
= Math.
min(S, distance
(X1, Y1, Y2
- B
- C, B
+ X2
)); S
= Math.
min(S, distance
(X1, Y1, A
+ B
- Y2, A
+ B
+ C
- X2
)); S
= Math.
min(S, distance
(X1, Y1, Y2
- B, B
+ C
+ X2
)); S
= Math.
min(S, distance
(X1, Y1,
-Y2,
-C
- X2
)); S
= Math.
min(S, distance
(X1, Y1, A
+ Y2,
-A
- C
+ X2
)); }
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBNYWluCnsKCXByaXZhdGUgc3RhdGljIGRvdWJsZSBkaXN0YW5jZShsb25nIFgxLCBsb25nIFkxLCBsb25nIFgyLCBsb25nIFkyKSAKCXsKICAgIAlyZXR1cm4gTWF0aC5zcXJ0KChYMS1YMikqKFgxLVgyKSArIChZMS1ZMikqKFkxLVkyKSk7Cgl9CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgdGhyb3dzIGphdmEubGFuZy5FeGNlcHRpb24KCXsKCQlTY2FubmVyIGluID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKCQlsb25nIEEgPSBpbi5uZXh0TG9uZygpOwoJCWxvbmcgQiA9IGluLm5leHRMb25nKCk7CgkJbG9uZyBDID0gaW4ubmV4dExvbmcoKTsKCQlsb25nIFgxID0gaW4ubmV4dExvbmcoKTsKCQlsb25nIFkxID0gaW4ubmV4dExvbmcoKTsKCQlsb25nIFgyID0gaW4ubmV4dExvbmcoKTsKCQlsb25nIFkyID0gaW4ubmV4dExvbmcoKTsKCQlsb25nIFoyID0gaW4ubmV4dExvbmcoKTsKCQlkb3VibGUgUyA9IDEwMDAwMDAwOwoJCWlmIChaMiA9PSAwKQogICAgCXsKICAgIAkJUyA9IGRpc3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