#include <bits/stdc++.h>
using namespace std;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }

const double INF = 1e18;
constexpr double EPS = 1e-8;

using Point = complex<double>;
#define X(a) real(a)
#define Y(a) imag(a)
struct Segment { Point a, b; };
struct Circle{ Point c; double r; };

template<class T> bool eq(const T &a, const T &b) { return abs(a - b) < EPS; }
namespace std {
  bool operator == (Point a, Point b) { return eq(X(a), X(b)) and eq(Y(a), Y(b)); }
  bool operator <  (Point a, Point b) { return X(a) == X(b) ? Y(a) < Y(b) : X(a) < X(b); }
  istream& operator >> (istream &is, Point &a) { double x, y; is >> x >> y; a.X(x); a.Y(y); return is; }
  double norm(Point p) { assert(0); } // complex ??? norm ?????????
}
double dot     (Point a, Point b) { return a.X() * b.X() + a.Y() * b.Y(); }
double cross   (Point a, Point b) { return a.X() * b.Y() - a.Y() * b.X(); }
double length2 (Point p         ) { return p.X() * p.X() + p.Y() * p.Y(); }
double length  (Point p         ) { return sqrt(length2(p)); }
double distance(Point a, Point b) { return length(a - b); }
Point  unit    (Point p         ) { return p / length(p); }
Point orthonormal(Point &p) { // ??£?????´???????????????
    Point p2 = Point(-1 * p.Y(), p.X()); // = rotate(p, 90);
    return p2 / length(p2);
}
enum ccw_t { // ??????????????¢??¨????????§ ccw_t ??? int ??§??????????????????????????¨???
    COUNTER_CLOCK_WISE = 1,
    CLOCK_WISE = -1,
    STRAIGHT_C_A_B = 2,
    STRAIGHT_A_B_C = -2,
    STRAIGHT_A_C_B = 0
};
ccw_t ccw(Point a, Point b, Point c){
    Point ab = b - a, ac = c - a;
    if( cross(ab,ac) > EPS ) return COUNTER_CLOCK_WISE; // +1 a-b-c ???????¨???????
    if( cross(ab,ac) < -EPS ) return CLOCK_WISE;        // -1 a-b-c ????¨???????
    if( dot(ab,ac) < -EPS ) return STRAIGHT_C_A_B;      // +2 c-a-b
    if( length2(ab) < length2(ac) )return STRAIGHT_A_B_C;     // -2 a-b-c or a==b
    return STRAIGHT_A_C_B;                              //  0 a-c-b or b==c or a==c
}
bool does_intersect(Segment a, Segment b){
    return (int)ccw(a.a, a.b, b.a) * (int)ccw(a.a, a.b, b.b) <= 0 &&
           (int)ccw(b.a, b.b, a.a) * (int)ccw(b.a, b.b, a.b) <= 0;
}

Point intersection(Segment a, Segment b) {
    assert(does_intersect(a, b));
    double p = cross(a.b - a.a, b.b - b.a);
    double q = cross(a.b - a.a, a.b - b.a);
    if(abs(p) < EPS and abs(q) < EPS) return a.a;
    if(abs(p) < EPS) assert(0);
    return q / p * (b.b - b.a) + b.a;
}
Point projection(Segment l, Point p) {
    double t = dot(p-l.a, l.a-l.b) / length2(l.a - l.b);
    Point ret = (l.a-l.b);
    return ret * t + l.a;
}

vector<Point> cross_points(Circle c1, Circle c2) {
    double d = distance(c1.c, c2.c);
    assert(d > 0);
    // c1.c ?????????c1,c2????????????????????´?????¨c1.c->c2.c ??????????????§????????¢
    double x = (pow(c1.r, 2) - pow(c2.r, 2) + pow(d, 2)) / (2 * d);
    if(c1.r < x) return {};
    double h = sqrt(pow(c1.r, 2) - pow(x, 2));    
    Point mid = unit(c2.c - c1.c) * x;
    if(eq(h, 0.0)) return { c1.c + mid };
    Point vertical = unit(Point(-Y(mid), X(mid))) * h; // ???????????????????????????
    return { c1.c + mid + vertical, c1.c + mid - vertical };
}

Point nearest_grid_point(Point p) {
    return Point{round(p.X()), round(p.Y())};
}


class Solver {
  public:
    bool solve() {
        Point a, b, c; cin >> a >> b >> c;
        if(a.X() == 0 and a.Y() == 0 and
           b.X() == 0 and b.Y() == 0 and
           c.X() == 0 and c.Y() == 0) return 0;
        
        auto calc_height = [&] (Point p1, Point p2, Point p3) {
            Point p1p = projection(Segment{a, c}, p1);
            Point p2p = projection(Segment{a, b}, p2);
            Segment p1_ac = Segment{p1, p1 + (p1p - p1) * 1e3};
            Segment p2_ab = Segment{p2, p2 + (p2p - p2) * 1e3};
            if(not does_intersect(p1_ac, p2_ab)) return INF;
            Point p = intersection(p1_ac, p2_ab);
            if(p == p1 or p == p2 or p == p3) return INF;
            double l_ah = distance(a, p1);
            double l_ap = distance(a, p);
            if(p == a) return l_ah;
            if(l_ah <= l_ap) return INF;
            return sqrt(l_ah * l_ah - l_ap * l_ap);
        };
        
        double ans = INF;
        repeat(x1, -100, 100 + 1) {
            repeat(y1, -100, 100 + 1) {
                Point p1 = Point(x1, y1);
                if(ccw(a, c, p1) != COUNTER_CLOCK_WISE) continue;
                double l1 = distance(a, p1);
                int y2_mx = min<int>(100, a.Y() + l1 + 0.5);
                int y2_mn = max<int>(-100, a.Y() - l1 - 0.5);               
                repeat(y2, y2_mn, y2_mx + 1) {
                    double dy = abs(a.Y() - y2);
                    double dx = sqrt(l1 * l1 - dy * dy);
                    for(Point p2_cand : {Point{a.X() + dx, (double)y2}, Point{a.X() - dx, (double)y2}}) {
                        Point p2 = nearest_grid_point(p2_cand);
                        
                        if(abs(p2.X()) > 100 or abs(p2.Y()) > 100) continue;
                        if(not eq(distance(a, p2), l1)) continue;
                        if(ccw(b, a, p2) != COUNTER_CLOCK_WISE) continue;
                        if(p1 == p2) continue;
                        if(ccw(b, a, p1) == COUNTER_CLOCK_WISE and ccw(p2, a, p1) != COUNTER_CLOCK_WISE) continue;
                        
                        double l2 = distance(p1, c);
                        double l3 = distance(p2, b);

                        Point p3;

                        bool ok = false;
                        for(Point p3_cand : cross_points(Circle{c, l2}, Circle{b, l3})) {
                            p3 = nearest_grid_point(p3_cand);
                            
                            if(abs(p3.X()) > 100 or abs(p3.Y()) > 100) continue;
                            if(ccw(c, b, p3) != COUNTER_CLOCK_WISE) continue;                            
                            if(p1 == p3 or p2 == p3) continue;
                            if(ccw(c, b, p2) == COUNTER_CLOCK_WISE and ccw(p3, b, p2) != COUNTER_CLOCK_WISE) continue;
                            if(ccw(a, c, p3) == COUNTER_CLOCK_WISE and ccw(p1, c, p3) != COUNTER_CLOCK_WISE) continue;
                            
                            if(eq(distance(c, p3), l2) and eq(distance(b, p3), l3)) {
                                ok = true;
                                break;
                            }
                        }
                        if(not ok) continue;
                        set_min(ans, calc_height(p1, p2, p3));
                    }
                }
            }
        }
        printf("%.10lf\n", (ans == INF ? -1 : ans));
        return 1;
    }
};

int main() {
    while(Solver().solve());
    return 0;
}
### Prompt

Develop a solution in Cpp to the problem described below:

You are constructing a triangular pyramid with a sheet of craft paper with grid lines. Its base and sides are all of triangular shape. You draw the base triangle and the three sides connected to the base on the paper, cut along the outer six edges, fold the edges of the base, and assemble them up as a pyramid.

You are given the coordinates of the base's three vertices, and are to determine the coordinates of the other three. All the vertices must have integral X- and Y-coordinate values between -100 and +100 inclusive. Your goal is to minimize the height of the pyramid satisfying these conditions. Figure 3 shows some examples.

<image>

Figure 3: Some craft paper drawings and side views of the assembled pyramids



Input

The input consists of multiple datasets, each in the following format.

X0 Y0 X1 Y1 X2 Y2

They are all integral numbers between -100 and +100 inclusive. (X0, Y0), (X1, Y1), (X2, Y2) are the coordinates of three vertices of the triangular base in counterclockwise order.

The end of the input is indicated by a line containing six zeros separated by a single space.

Output

For each dataset, answer a single number in a separate line. If you can choose three vertices (Xa, Ya), (Xb, Yb) and (Xc, Yc) whose coordinates are all integral values between -100 and +100 inclusive, and triangles (X0, Y0 )-(X1, Y1)-(Xa, Ya), (X1, Y1)-(X2, Y2)-(Xb, Yb), (X2, Y2)-(X0, Y0)-(Xc, Yc) and (X0, Y0)-(X1, Y1)-(X2, Y2) do not overlap each other (in the XY-plane), and can be assembled as a triangular pyramid of positive (non-zero) height, output the minimum height among such pyramids. Otherwise, output -1.

You may assume that the height is, if positive (non-zero), not less than 0.00001. The output should not contain an error greater than 0.00001.

Example

Input

0 0 1 0 0 1
0 0 5 0 2 5
-100 -100 100 -100 0 100
-72 -72 72 -72 0 72
0 0 0 0 0 0


Output

2
1.49666
-1
8.52936

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }

const double INF = 1e18;
constexpr double EPS = 1e-8;

using Point = complex<double>;
#define X(a) real(a)
#define Y(a) imag(a)
struct Segment { Point a, b; };
struct Circle{ Point c; double r; };

template<class T> bool eq(const T &a, const T &b) { return abs(a - b) < EPS; }
namespace std {
  bool operator == (Point a, Point b) { return eq(X(a), X(b)) and eq(Y(a), Y(b)); }
  bool operator <  (Point a, Point b) { return X(a) == X(b) ? Y(a) < Y(b) : X(a) < X(b); }
  istream& operator >> (istream &is, Point &a) { double x, y; is >> x >> y; a.X(x); a.Y(y); return is; }
  double norm(Point p) { assert(0); } // complex ??? norm ?????????
}
double dot     (Point a, Point b) { return a.X() * b.X() + a.Y() * b.Y(); }
double cross   (Point a, Point b) { return a.X() * b.Y() - a.Y() * b.X(); }
double length2 (Point p         ) { return p.X() * p.X() + p.Y() * p.Y(); }
double length  (Point p         ) { return sqrt(length2(p)); }
double distance(Point a, Point b) { return length(a - b); }
Point  unit    (Point p         ) { return p / length(p); }
Point orthonormal(Point &p) { // ??£?????´???????????????
    Point p2 = Point(-1 * p.Y(), p.X()); // = rotate(p, 90);
    return p2 / length(p2);
}
enum ccw_t { // ??????????????¢??¨????????§ ccw_t ??? int ??§??????????????????????????¨???
    COUNTER_CLOCK_WISE = 1,
    CLOCK_WISE = -1,
    STRAIGHT_C_A_B = 2,
    STRAIGHT_A_B_C = -2,
    STRAIGHT_A_C_B = 0
};
ccw_t ccw(Point a, Point b, Point c){
    Point ab = b - a, ac = c - a;
    if( cross(ab,ac) > EPS ) return COUNTER_CLOCK_WISE; // +1 a-b-c ???????¨???????
    if( cross(ab,ac) < -EPS ) return CLOCK_WISE;        // -1 a-b-c ????¨???????
    if( dot(ab,ac) < -EPS ) return STRAIGHT_C_A_B;      // +2 c-a-b
    if( length2(ab) < length2(ac) )return STRAIGHT_A_B_C;     // -2 a-b-c or a==b
    return STRAIGHT_A_C_B;                              //  0 a-c-b or b==c or a==c
}
bool does_intersect(Segment a, Segment b){
    return (int)ccw(a.a, a.b, b.a) * (int)ccw(a.a, a.b, b.b) <= 0 &&
           (int)ccw(b.a, b.b, a.a) * (int)ccw(b.a, b.b, a.b) <= 0;
}

Point intersection(Segment a, Segment b) {
    assert(does_intersect(a, b));
    double p = cross(a.b - a.a, b.b - b.a);
    double q = cross(a.b - a.a, a.b - b.a);
    if(abs(p) < EPS and abs(q) < EPS) return a.a;
    if(abs(p) < EPS) assert(0);
    return q / p * (b.b - b.a) + b.a;
}
Point projection(Segment l, Point p) {
    double t = dot(p-l.a, l.a-l.b) / length2(l.a - l.b);
    Point ret = (l.a-l.b);
    return ret * t + l.a;
}

vector<Point> cross_points(Circle c1, Circle c2) {
    double d = distance(c1.c, c2.c);
    assert(d > 0);
    // c1.c ?????????c1,c2????????????????????´?????¨c1.c->c2.c ??????????????§????????¢
    double x = (pow(c1.r, 2) - pow(c2.r, 2) + pow(d, 2)) / (2 * d);
    if(c1.r < x) return {};
    double h = sqrt(pow(c1.r, 2) - pow(x, 2));    
    Point mid = unit(c2.c - c1.c) * x;
    if(eq(h, 0.0)) return { c1.c + mid };
    Point vertical = unit(Point(-Y(mid), X(mid))) * h; // ???????????????????????????
    return { c1.c + mid + vertical, c1.c + mid - vertical };
}

Point nearest_grid_point(Point p) {
    return Point{round(p.X()), round(p.Y())};
}


class Solver {
  public:
    bool solve() {
        Point a, b, c; cin >> a >> b >> c;
        if(a.X() == 0 and a.Y() == 0 and
           b.X() == 0 and b.Y() == 0 and
           c.X() == 0 and c.Y() == 0) return 0;
        
        auto calc_height = [&] (Point p1, Point p2, Point p3) {
            Point p1p = projection(Segment{a, c}, p1);
            Point p2p = projection(Segment{a, b}, p2);
            Segment p1_ac = Segment{p1, p1 + (p1p - p1) * 1e3};
            Segment p2_ab = Segment{p2, p2 + (p2p - p2) * 1e3};
            if(not does_intersect(p1_ac, p2_ab)) return INF;
            Point p = intersection(p1_ac, p2_ab);
            if(p == p1 or p == p2 or p == p3) return INF;
            double l_ah = distance(a, p1);
            double l_ap = distance(a, p);
            if(p == a) return l_ah;
            if(l_ah <= l_ap) return INF;
            return sqrt(l_ah * l_ah - l_ap * l_ap);
        };
        
        double ans = INF;
        repeat(x1, -100, 100 + 1) {
            repeat(y1, -100, 100 + 1) {
                Point p1 = Point(x1, y1);
                if(ccw(a, c, p1) != COUNTER_CLOCK_WISE) continue;
                double l1 = distance(a, p1);
                int y2_mx = min<int>(100, a.Y() + l1 + 0.5);
                int y2_mn = max<int>(-100, a.Y() - l1 - 0.5);               
                repeat(y2, y2_mn, y2_mx + 1) {
                    double dy = abs(a.Y() - y2);
                    double dx = sqrt(l1 * l1 - dy * dy);
                    for(Point p2_cand : {Point{a.X() + dx, (double)y2}, Point{a.X() - dx, (double)y2}}) {
                        Point p2 = nearest_grid_point(p2_cand);
                        
                        if(abs(p2.X()) > 100 or abs(p2.Y()) > 100) continue;
                        if(not eq(distance(a, p2), l1)) continue;
                        if(ccw(b, a, p2) != COUNTER_CLOCK_WISE) continue;
                        if(p1 == p2) continue;
                        if(ccw(b, a, p1) == COUNTER_CLOCK_WISE and ccw(p2, a, p1) != COUNTER_CLOCK_WISE) continue;
                        
                        double l2 = distance(p1, c);
                        double l3 = distance(p2, b);

                        Point p3;

                        bool ok = false;
                        for(Point p3_cand : cross_points(Circle{c, l2}, Circle{b, l3})) {
                            p3 = nearest_grid_point(p3_cand);
                            
                            if(abs(p3.X()) > 100 or abs(p3.Y()) > 100) continue;
                            if(ccw(c, b, p3) != COUNTER_CLOCK_WISE) continue;                            
                            if(p1 == p3 or p2 == p3) continue;
                            if(ccw(c, b, p2) == COUNTER_CLOCK_WISE and ccw(p3, b, p2) != COUNTER_CLOCK_WISE) continue;
                            if(ccw(a, c, p3) == COUNTER_CLOCK_WISE and ccw(p1, c, p3) != COUNTER_CLOCK_WISE) continue;
                            
                            if(eq(distance(c, p3), l2) and eq(distance(b, p3), l3)) {
                                ok = true;
                                break;
                            }
                        }
                        if(not ok) continue;
                        set_min(ans, calc_height(p1, p2, p3));
                    }
                }
            }
        }
        printf("%.10lf\n", (ans == INF ? -1 : ans));
        return 1;
    }
};

int main() {
    while(Solver().solve());
    return 0;
}
```