1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define _upgrade                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template <typename _T>
inline void _DBG(const char *s, _T x)
{
    cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a)
{
    while (*s != ',')
        cerr << *s++;
    cerr << " = " << x << ',';
    _DBG(s + 1, a...);
}

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr \
    if (0)   \
    cout
#endif

// ********************** CODE ********************** //

namespace GEO
{
#define ALL(X) X.begin(), X.end()
#define FOR(I, A, B) for (int(I) = (A); (I) <= (B); (I)++)
#define FORW(I, A, B) for (int(I) = (A); (I) < (B); (I)++)
#define FORD(I, A, B) for (int(I) = (A); (I) >= (B); (I)--)
#define CLEAR(X) memset(X, 0, sizeof(X))
#define SIZE(X) int(X.size())
#define CONTAINS(A, X) (A.find(X) != A.end())
#define PB push_back
#define MP make_pair
#define X first
#define Y second
using namespace std;
typedef signed long long slong;
typedef long double ldouble;
const slong INF = 1000000100;
const ldouble EPS = 1e-6;
const ldouble PI = 4 * atanl(1.0);
typedef pair<ldouble, ldouble> point;
typedef pair<point, point> segment;
inline bool is_zero(const ldouble &x) { return -EPS <= x and x <= EPS; }
inline point operator+(const point &a, const point &b) { return point(a.X + b.X, a.Y + b.Y); }
inline point operator-(const point &a, const point &b) { return point(a.X - b.X, a.Y - b.Y); }
inline point operator*(const point &a, ldouble t) { return point(a.X * t, a.Y * t); }
inline point operator/(const point &a, ldouble t) { return point(a.X / t, a.Y / t); }
inline ldouble cp(const point &a, const point &b)
{
    return a.X * b.Y - a.Y * b.X;
}
inline ldouble dp(const point &a, const point &b)
{
    return a.X * b.X + a.Y * b.Y;
}
inline ldouble distance(const point &a, const point &b)
{
    return sqrtl((b.X - a.X) * (b.X - a.X) + (b.Y - a.Y) * (b.Y - a.Y));
}
inline bool on_right(const point &a, const point &b, const point &c)
{
    return cp(c - a, b - a) > EPS;
}
double polygon_area(const vector<point> &A)
{
    ldouble result = 0.0;
    if (SIZE(A) <= 2)
        return 0;
    FORW(i, 2, SIZE(A))
    result += cp(A[i] - A[0], A[i - 1] - A[0]);
    return abs(result / 2);
}
point projection(const point &p, const segment &u)
{
    return u.X + (u.Y - u.X) * (dp(p - u.X, u.Y - u.X) / dp(u.Y - u.X, u.Y - u.X));
}
inline bool between(const point &a, const point &b, const point &c)
{
    return min(b.X, c.X) - a.X < EPS and a.X - max(b.X, c.X) < EPS and min(b.Y, c.Y) - a.Y < EPS and a.Y - max(b.Y, c.Y) < EPS;
}
inline bool on_segment(const point &p, const segment &u)
{
    return between(p, u.X, u.Y) and is_zero(cp(u.X - p, u.Y - p));
}
inline ldouble distance_point_line(const point &p, const segment &u)
{
    return abs(cp(p - u.X, p - u.Y) / distance(u.X, u.Y));
}
inline ldouble distance_point_segment(const point &p, const segment &u)
{
    if (on_segment(projection(p, u), u))
        return abs(distance_point_line(p, u));
    else
        return min(distance(u.X, p), distance(u.Y, p));
}
inline ldouble angle(const point &a, const point &o, const point &b)
{
    ldouble result = atan2l((b - o).Y, (b - o).X) - atan2l((a - o).Y, (a - o).X);
    if (result < -EPS)
        result += 2 * PI;
    return result;
}
inline point point_reflection(const point &p, const point &s)
{
    return p + (s - p) * 2;
}
inline point axial_reflection(const point &p, const segment &u)
{
    return point_reflection(p, projection(p, u));
}
/* result: counter - clockwise oriented polygon */
vector<point> convex_hull(vector<point> A)
{
    vector<point> R;
    sort(ALL(A));
    R.push_back(A[0]);
    FOR(_, 0, 1)
    {
        int t = SIZE(R);
        FORW(i, 1, SIZE(A))
        {
            while (SIZE(R) > t and !on_right(A[i], R.back(), R.rbegin()[1]))
                R.pop_back();
            R.push_back(A[i]);
        }
        reverse(ALL(A));
    }
    if (SIZE(R) > 1)
        R.pop_back();
    return move(R);
}
inline point rotate90_origin(const point &p)
{
    return point(p.Y, -p.X);
}
inline point rotate90(const point &p, const point &o)
{
    return o + rotate90_origin(p - o);
}
inline point rotate_origin(const point &p, ldouble theta)
{
    theta = -theta;
    ldouble s = sinl(theta);
    ldouble c = cosl(theta);
    return point(p.X * c - p.Y * s, p.X * s + p.Y * c);
}
inline point rotate(const point &p, const point &o, ldouble theta)
{
    return o + rotate_origin(p - o, theta);
}
bool parallel(const segment &u, const segment &v)
{
    return is_zero(cp(u.Y - u.X, v.Y - v.X));
}
bool perpendicular(const segment &u, const segment &v)
{
    return is_zero(dp(u.Y - u.X, v.Y - v.X));
}
segment segment_bisector(const segment &u)
{
    point p = (u.X + u.Y) / 2;
    return segment(p, rotate90(u.Y, p));
}
segment bisector(const point &a, const point &o, const point &b)
{
    ldouble c = distance(o, b) / distance(o, a);
    return segment(o, b + (a - o) * c);
}
pair<bool, point> intersection_line_line(const segment &u, const segment &v)
{
    ldouble p = cp(u.Y - v.X, u.Y - u.X);
    ldouble q = cp(v.Y - v.X, u.Y - u.X);
    if (is_zero(q))
        return {false, point()};
    return {true, v.X + (v.Y - v.X) * (p / q)};
}
pair<bool, point> intersection_line_segment(const segment &u, const segment &v)
{
    auto R = intersection_line_line(u, v);
    if (!R.X)
        return {false, point()};
    if (!between(R.Y, v.X, v.Y))
        return {false, point()};
    return R;
}
pair<bool, point> intersection_segment_segment(const segment &u, const segment &v)
{
    auto R = intersection_line_line(u, v);
    if (!R.X)
        return {false, point()};
    if (!between(R.Y, u.X, u.Y))
        return {false, point()};
    if (!between(R.Y, v.X, v.Y))
        return {false, point()};
    return R;
}
pair<point, point> nearest_points(vector<point> P)
{
    sort(ALL(P));
    set<pair<ldouble, int>> S;
    pair<point, point> result(P[0], P[1]);
    ldouble best_dist = distance(P[0], P[1]);
    FORW(i, 0, SIZE(P))
    {
        vector<int> to_erase;
        auto p = S.lower_bound(MP(P[i].Y - best_dist - EPS, -INF));
        auto q = S.upper_bound(MP(P[i].Y + best_dist + EPS, INF));
        for (auto it = p; it != q; ++it)
        {
            if (distance(P[i], P[it->Y]) < best_dist)
            {
                result = MP(P[i], P[it->Y]);
                best_dist = distance(P[i], P[it->Y]);
            }
            if (P[i].X - P[it->Y].X > best_dist)
                to_erase.PB(it->Y);
        }
        for (int t : to_erase)
            S.erase(MP(P[t].Y, t));
        S.insert(MP(P[i].Y, i));
    }
    return result;
}
ldouble diameter(vector<point> P)
{
    P = convex_hull(P);
    ldouble result = 0;
    int j = 0, n = SIZE(P);
    if (n == 1)
        return 0;
    if (n == 2)
        return distance(P[0], P[1]);
    FORW(i, 0, n)
    {
        while (true)
        {
            result = max(result, distance(P[i], P[j]));
            if (cp(P[(i + 1) % n] - P[i], P[(j + 1) % n] - P[j]) > EPS)
                break;
            j = (j + 1) % n;
        }
    }
    return result;
}
bool in_polygon(const vector<point> &P, int right_id, point p)
{
    point x = P[0];
    point y = P[right_id];
    if (p < x or p > y)
        return false;
    ldouble t = cp(p - x, y - x);
    if (t > EPS)
    {
        auto it = lower_bound(P.begin() + 1, P.begin() + right_id, p);
        return !on_right(*it, p, it[-1]);
    }
    else if (t < -EPS)
    {
        auto it = upper_bound(P.rbegin(), P.rend() - right_id - 1, p);
        return !on_right(it == P.rbegin() ? P[0] : it[-1], p, *it);
    }
    else
    {
        return on_segment(p, segment(x, y));
    }
}
inline ldouble sq_length(const point &p)
{
    return p.X * p.X + p.Y * p.Y;
}
inline ldouble length(const point &p)
{
    return sqrtl(sq_length(p));
}
inline point norm(const point &p)
{
    ldouble l = length(p);
    return point(p.X / l, p.Y / l);
}
inline int type(const point &p)
{
    return p.Y > EPS or (p.Y >= -EPS && p.X > EPS);
}
bool compare_angle(const point &a, const point &b)
{
    int at = type(a), bt = type(b);
    if (at != bt)
        return at < bt;
    ldouble prod = cp(a, b);
    if (abs(prod) > EPS)
        return prod > EPS;
    return sq_length(a) < sq_length(b) - EPS;
}
struct line
{
    point o, v;
    line(const point &a, const point &b) : o(a), v(norm(b - a)) {}
};
bool operator<(const line &a, const line &l)
{
    if (abs(a.v.X - l.v.X) > EPS or abs(a.v.Y - l.v.Y) > EPS)
        return compare_angle(
            a.v, l.v);
    return cp(a.v, l.o - a.o) < -EPS;
}
inline segment to_segment(const line &a)
{
    return segment(a.o, a.o + a.v);
}
inline ldouble distance_point_line(const point &p, const line &u)
{
    return cp(p - u.o, p - (u.o + u.v));
}
vector<point> halfcoat(vector<line> h)
{
    const static int MAXN = 40020;
    static const ldouble Z = 1e6;
    static point p[MAXN];
    static point box[4] = {
        point(Z, -Z),
        point(Z, Z),
        point(-Z, Z),
        point(-Z, -Z)};
    FORW(i, 0, 4)
    h.PB(line(box[i], box[(i + 1) % 4]));
    int n = SIZE(h), z = 0;
    sort(ALL(h));
    FORW(i, 0, n)
    if (i == 0 or (abs(h[i].v.X - h[i - 1].v.X) > EPS or abs(h[i].v.Y - h[i - 1].v.Y) > EPS))
        h[z++] = h[i];
    n = z;
    int m = 0, del = 0;
    FORW(i, 1, n)
    {
        while (m > del and distance_point_line(p[m - 1], h[i]) < EPS)
            --m;
        while (m > del and distance_point_line(p[del], h[i]) < EPS)
            ++del;
        if (del == m and cp(h[m].v, h[i].v) < EPS)
            return {};
        point q = intersection_line_line(to_segment(h[i]), to_segment(h[m])).Y;
        if (distance_point_line(q, h[del]) > -EPS)
            p[m++] = q, h[m] = h[i];
    }
    rotate(p, p + del, p + m);
    rotate(h.begin(), h.begin() + del, h.end());
    m -= del;
    if (m == 0)
        return {};
    point q = intersection_line_line(to_segment(h[0]), to_segment(h[m])).Y;
    p[m++] = q;
    return vector<point>(p, p + m);
}
} // namespace GEO

typedef long double T;

const T eps = 1e-6;

bool eq(T x, T y)
{
    return abs(x - y) < eps;
}

struct point
{
    T x, y;
    point() {}
    point(T _x, T _y) : x(_x), y(_y) {}
    point(pair<T, T> p) : x(p.first), y(p.second) {}
    point operator+(point p)
    {
        return point(x + p.x, y + p.y);
    }
    point operator-(point p)
    {
        return point(x - p.x, y - p.y);
    }
    T norm()
    {
        return x * x + y * y;
    }
    T len()
    {
        return sqrt(norm());
    }
    void print()
    {
        cout << x << " " << y;
    }
    void print(int prec)
    {
        cout << fixed << setprecision(prec) << x << " " << y;
    }
    void println()
    {
        cout << x << " " << y << "\n";
    }
    void println(int prec)
    {
        cout << fixed << setprecision(prec) << x << " " << y << "\n";
    }
};

bool operator <(const point &p1, const point &p2)
{
    if(eq(p1.x, p2.x) && eq(p1.y, p2.y))
    {
        return false;
    }
    if(eq(p1.x, p2.x))
    {
        return p1.y < p2.y;
    }
    return p1.x < p2.x;
}

bool operator==(const point &p1, const point &p2)
{
    return eq(p1.x, p2.x) && eq(p1.y, p2.y);
}

struct line
{
    T a, b, c;
    line(T _a, T _b, T _c) : a(_a), b(_b), c(_c) {}
    line(point p, point q) : a(p.y - q.y), b(q.x - p.x), c((q.y - p.y) * p.x - (q.x - p.x) * p.y) {}
};

point operator*(T alpha, point p)
{
    return point(alpha * p.x, alpha * p.y);
}

point operator/(T alpha, point p)
{
    return point(p.x / alpha, p.y / alpha);
}

point rotate(point p, T alpha)
{
    T s = sin(alpha), c = cos(alpha);
    return point(p.x * c - p.y * s, p.x * s + p.y * c);
}

point rotate(point p, point o, T alpha)
{
    return rotate(p - o, alpha) + o;
}

T dist(point p, point q)
{
    return (p - q).len();
}

T dist(point p, line l)
{
    return abs(l.a * p.x + l.b * p.y + l.c) / sqrt(l.a * l.a + l.b * l.b);
}

point intersection(line l, line k)
{
    return point((l.b * k.c - k.b * l.c) / (k.b * l.a - l.b * k.a),
                 (l.a * k.c - k.a * l.c) / (k.a * l.b - l.a * k.b));
}

point projection(point p, line l)
{
    line k(-l.b, l.a, l.b * p.x - l.a * p.y);
    return intersection(l, k);
}

T vecp(point a, point b, point c)
{
    return (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y);
}

T scap(point a, point b, point c)
{
    return (b.x - a.x) * (c.x - a.x) + (b.y - a.y) * (c.y - a.y);
}

struct convex_hull
{
    int n;
    vector<point> pts, ch, tmp;

    bool check(point &a, point &b, point &c)
    {
        return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x) > -eps;
    }

    vector<point> make_half(vector<point> &ans)
    {
        ans = {pts[0], pts[1]};
        for (int i = 2; i < n; i++)
        {
            int x = sz(ans) - 1;
            while (x > 0 && check(ans[x - 1], ans[x], pts[i]))
                ans.pop_back(), x--;
            ans.push_back(pts[i]);
        }
        ans.pop_back();
        return ans;
    }

    convex_hull(vector<point> &vec) : n(sz(vec)), pts(vec)
    {
        sort(all(pts));
        make_half(ch);
        reverse(all(pts));
        make_half(tmp);
        for (auto &x : tmp)
            ch.push_back(x);
        tmp.clear();
    }
};

const int N = 105;
int n;
point P[N][2];
vector<GEO::line> vec;
vector < line > nvec;

int main()
{
    _upgrade
    
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int p = 0; p < 2; p++)
            cin >> P[i][p].x >> P[i][p].y;

    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            for (int pi = 0; pi < 2; pi++)
            {
                for (int pj = 0; pj < 2; pj++)
                {
                    line l(P[i][pi], P[j][pj]);
                    GEO::point ii({P[i][pi].x, P[i][pi].y});
                    GEO::point jj({P[j][pj].x, P[j][pj].y});
                    bool flag = true;
                    for (int k = 0; k < n; k++)
                    {
                        if (k == i || k == j)
                            continue;
                        if (l.a * P[k][0].x + l.b * P[k][0].y + l.c > eps && l.a * P[k][1].x + l.b * P[k][1].y + l.c > eps)
                        {
                            flag = false;
                        }
                    }
                    if (flag == true)
                    {
                        vec.push_back(GEO::line(jj, ii));
                        nvec.push_back(l);
                    }
                    l = {-l.a, -l.b, -l.c};
                    flag = true;
                    for (int k = 0; k < n; k++)
                    {
                        if (k == i || k == j)
                            continue;
                        if (l.a * P[k][0].x + l.b * P[k][0].y + l.c > eps && l.a * P[k][1].x + l.b * P[k][1].y + l.c > eps)
                        {
                            flag = false;
                        }
                    }
                    if (flag == true)
                    {
                        vec.push_back(GEO::line(ii, jj));
                        nvec.push_back(l);
                    }
                    l = {-l.a, -l.b, -l.c};
                }
            }
        }
    }

    vector<point> my;
    vector < GEO::point > gg = GEO::halfcoat(vec);
    for(auto p: gg)
    {
        my.push_back(point(p.first, p.second));
    }


    if (my.empty())
    {
        cout << fixed << setprecision(18) << 0.0 << "\n";
        return 0;
    }

    for(auto l: nvec)
    {
        if(l.a * my[0].x + l.b * my[0].y + l.c > eps)
        {
            my.clear();
            break;
        }
    }

    if(my.empty())
    {
        cout << fixed << setprecision(18) << 0.0 << "\n";
        return 0;
    }

    sort(all(my));
    my.erase(unique(all(my)), my.end());

    auto ch = convex_hull(my);

    T ans = vecp({0, 0}, ch.ch.back(), ch.ch[0]);
    for (int i = 1; i < sz(ch.ch); i++)
    {
        ans += vecp({0, 0}, ch.ch[i - 1], ch.ch[i]);
    }
    cout << fixed << setprecision(18) << abs(ans) / 2.0 << "\n";

    return 0;
}