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
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << fixed << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (c it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(x...) " [" #x ": " << (x) << "] "

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
template <typename A, typename B>
using unordered_map2 = __gnu_pbds::gp_hash_table<A, B>;
using namespace __gnu_pbds;
template <typename T> using ordered_set =
  __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag,
                   __gnu_pbds::tree_order_statistics_node_update>;
// ordered_set<int> s; s.insert(1); s.insert(2);
// s.order_of_key(1);    // Out: 0.
// *s.find_by_order(1);  // Out: 2.

using ld = long double;
using ll = long long;

constexpr int mod = 1000 * 1000 * 1000 + 7;
constexpr int odw2 = (mod + 1) / 2;

void OdejmijOd(int& a, int b) { a -= b; if (a < 0) a += mod; }
int Odejmij(int a, int b) { OdejmijOd(a, b); return a; }
void DodajDo(int& a, int b) { a += b; if (a >= mod) a -= mod; }
int Dodaj(int a, int b) { DodajDo(a, b); return a; }
int Mnoz(int a, int b) { return (ll) a * b % mod; }
void MnozDo(int& a, int b) { a = Mnoz(a, b); }
int Pot(int a, ll b) { int res = 1; while (b) { if (b % 2 == 1) MnozDo(res, a); a = Mnoz(a, a); b /= 2; } return res; }
int Odw(int a) { return Pot(a, mod - 2); }
void PodzielDo(int& a, int b) { MnozDo(a, Odw(b)); }
int Podziel(int a, int b) { return Mnoz(a, Odw(b)); }
int Moduluj(ll x) { x %= mod; if (x < 0) x += mod; return x; }

template <typename T> T Maxi(T& a, T b) { return a = max(a, b); }
template <typename T> T Mini(T& a, T b) { return a = min(a, b); }

constexpr int Box = 10;

// Int z przedziału [-Ogr, Ogr].
template <ll Ogr>
struct Int {
  ll value;

  Int() = default;

  explicit Int(ll val) : value(val) {
    #ifdef LOCAL
    assert(-Ogr <= value and value <= Ogr);
    #endif
  }

  template <ll Ogr2>
  Int(Int<Ogr2> i) : value(i.value) {
    static_assert(Ogr2 <= Ogr, "Ogr can be only bigger");
  }

  void Check() const {
    #ifdef LOCAL
    assert(-Ogr <= value and value <= Ogr);
    #endif
  }

  ld ToLd() const {
    return value;
  }
};

template <ll Ogr>
istream& operator>>(istream& stream, Int<Ogr>& i) {
  #ifdef LOCAL
  stream >> i.value;
  i.Check();
  return stream;
  #else
  return stream >> i.value;
  #endif
}

template <ll Ogr>
ostream& operator<<(ostream& stream, Int<Ogr> i) {
  return stream << i.value;
}

#define OPERATOR(op)                                                     \
    template <ll Ogr>                                                    \
    bool operator op(ll v, Int<Ogr> i) { return v op i.value; }          \
    template <ll Ogr>                                                    \
    bool operator op(Int<Ogr> i, ll v) { return i.value op v; }          \
    template <ll A, ll B>                                                \
    bool operator op(Int<A> a, Int<B> b) { return a.value op b.value; }
OPERATOR(==)
OPERATOR(!=)
OPERATOR(<)
OPERATOR(>)
OPERATOR(<=)
OPERATOR(>=)
#undef OPERATOR

template <ll Ogr>
Int<Ogr> operator-(Int<Ogr> i) {
  return Int<Ogr>(-i.value);
}

template <ll Ogr>
Int<Ogr> operator+(Int<Ogr> i) {
  return i;
}

template <ll A, ll B>
Int<A + B> operator+(Int<A> a, Int<B> b) {
  return Int<A + B>(a.value + b.value);
}

template <ll A, ll B>
Int<A + B> operator-(Int<A> a, Int<B> b) {
  return Int<A + B>(a.value - b.value);
}

template <ll A, ll B>
Int<A * B> operator*(Int<A> a, Int<B> b) {
  return Int<A * B>(a.value * b.value);
}

template <ll A, ll B>
Int<B - 1> operator%(Int<A> a, Int<B> b) {
  return Int<B - 1>(a.value % b.value);
}

template <ll A, ll B>
Int<A> Podziel(Int<A> a, Int<B> b) {
  return Int<A>(a.value / b.value);
}

template <ll Ogr>
Int<Ogr> Gcd(Int<Ogr> a, Int<Ogr> b) {
  if (a == Int<0>(0)) {
    return b;
  }
  return Gcd(Int<Ogr>(b % a), a);
}

template <ll Ogr>
Int<Ogr> Abs(Int<Ogr> a) {
  return Int<Ogr>(abs(a.value));
}

template <ll L, ll M>
struct Frac {
  Int<L> l;
  Int<M> m;

  Frac() = default;

  Frac(Int<L> l_, Int<M> m_) : l(l_), m(m_) {
    #ifdef LOCAL
    assert(m != Int<0>(0));
    #endif
    if (m < Int<0>(0)) {
      l = -l;
      m = -m;
    }
  }

  template <ll L2, ll M2>
  Frac(const Frac<L2, M2>& f) : l(f.l), m(f.m) {}

  ld ToLd() const {
    return l.ToLd() / m.ToLd();
  }
};

template <ll L, ll M>
ostream& operator<<(ostream& stream, const Frac<L, M>& f) {
  return stream << f.l << "/" << f.m;
}

template <ll A>
Frac<A, 1> ToFrac(Int<A> i) {
  return Frac<A, 1>(i, Int<1>(1));
}

template <ll A, ll B>
Frac<A, B> operator/(Int<A> a, Int<B> b) {
  return Frac<A, B>(a, b);
}

template <ll A, ll B>
Frac<A, B> operator-(const Frac<A, B>& f) {
  return Frac<A, B>(-f.l, f.m);
}

template <ll A, ll B>
Frac<A, B> operator+(const Frac<A, B>& f) {
  return f;
}

template <ll L1, ll M1, ll L2, ll M2>
Frac<L1 * M2 + L2 * M1, M1 * M2> operator+(const Frac<L1, M1>& a,
                                           const Frac<L2, M2>& b) {
  return Frac<L1 * M2 + L2 * M1, M1 * M2>(a.l * b.m + b.l * a.m, a.m * b.m);
}

template <ll L1, ll M1, ll L2, ll M2>
Frac<L1 * M2 + L2 * M1, M1 * M2> operator-(const Frac<L1, M1>& a,
                                           const Frac<L2, M2>& b) {
  return Frac<L1 * M2 + L2 * M1, M1 * M2>(a.l * b.m - b.l * a.m, a.m * b.m);
}

template <ll L1, ll M1, ll L2, ll M2>
Frac<L1 * L2, M1 * M2> operator*(const Frac<L1, M1>& a, const Frac<L2, M2>& b) {
  return Frac<L1 * L2, M1 * M2>(a.l * b.l, a.m * b.m);
}

template <ll L1, ll M1, ll L2, ll M2>
Frac<L1 * M2, M1 * L2> operator/(const Frac<L1, M1>& a, const Frac<L2, M2>& b) {
  return Frac<L1 * M2, M1 * L2>(a.l * b.m, a.m * b.l);
}

#define OPERATOR(op)                                   \
    template <ll L1, ll M1, ll O>                      \
    auto operator op(const Frac<L1, M1>& f, Int<O> i)  \
        -> decltype(f op ToFrac(i)) {                  \
      return f op ToFrac(i);                           \
    }                                                  \
    template <ll L1, ll M1, ll O>                      \
    auto operator op(Int<O> i, const Frac<L1, M1>& f)  \
        -> decltype(ToFrac(i) op f) {                  \
      return ToFrac(i) op f;                           \
    }
OPERATOR(+)
OPERATOR(-)
OPERATOR(*)
OPERATOR(/)
#undef OPERATOR

#define OPERATOR(op)                                                          \
    template <ll L1, ll M1, ll L2, ll M2>                                     \
    bool operator op(const Frac<L1, M1>& a, const Frac<L2, M2>& b) {          \
      static_assert(L1 * M2 <= numeric_limits<ll>::max(), "overflow check");  \
      static_assert(L2 * M1 <= numeric_limits<ll>::max(), "overflow check");  \
      return a.l * b.m op b.l * a.m;                                          \
    }
OPERATOR(==)
OPERATOR(!=)
OPERATOR(<)
OPERATOR(>)
OPERATOR(<=)
OPERATOR(>=)
#undef OPERATOR

template <typename T>
struct P {
  T x, y;

  P() = default;

  P(T x_, T y_) : x(x_), y(y_) {}

  P Perp() const {
    return P(-y, x);
  }

//  auto LenSquared() const -> decltype(x * x + y * y) {
//    return x * x + y * y;
//  }

  bool Above() const {
    return y > Int<0>(0) or (y == Int<0>(0) and x > Int<0>(0));
  }
};

template <typename T>
debug& operator<<(debug& deb, const P<T>& p) {
  return deb << "(" << p.x << ", " << p.y << ")";
}

template <typename T>
P<T> operator-(const P<T>& p) {
  return P<T>(-p.x, -p.y);
}

template <typename T>
P<T> operator+(const P<T>& p) {
  return p;
}

template <typename A, typename B>
bool operator==(const P<A>& a, const P<B>& b) {
  return a.x == b.x and a.y == b.y;
}

template <typename A, typename B>
bool operator!=(const P<A>& a, const P<B>& b) {
  return a.x != b.x or a.y != b.y;
}

template <typename A, typename B>
auto operator*(const P<A>& a, const P<B>& b)
    -> decltype(a.x * b.y - a.y * b.x) {
  return a.x * b.y - a.y * b.x;
}

template <typename A, typename B>
auto operator%(const P<A>& a, const P<B>& b)
    -> decltype(a.x * b.x + a.y * b.y) {
  return a.x * b.x + a.y * b.y;
}

template <typename A, typename B>
auto operator+(const P<A>& a, const P<B>& b) -> P<decltype(A() + B())> {
  return P<decltype(A() + B())>(a.x + b.x, a.y + b.y);
}

template <typename A, typename B>
auto operator-(const P<A>& a, const P<B>& b) -> P<decltype(A() - B())> {
  return P<decltype(A() + B())>(a.x - b.x, a.y - b.y);
}

template <typename A, typename B>
auto operator*(const P<A>& a, const B& b) -> P<decltype(A() * B())> {
  return P<decltype(A() * B())>(a.x * b, a.y * b);
}

template <typename A, typename B>
auto operator*(const A& a, const P<B>& b) -> P<decltype(A() * B())> {
  return P<decltype(A() * B())>(a * b.x, a * b.y);
}

template <typename A, typename B>
auto operator/(const P<A>& a, const B& b) -> P<decltype(A() / B())> {
  return P<decltype(A() / B())>(a.x / b, a.y / b);
}

template <typename T, typename C>
struct Line {
  P<T> dir;
  C c;

  Line() = default;

  Line(const P<T>& dir_, const C& c_) : dir(dir_), c(c_) {
    #ifdef LOCAL
    //assert(dir.LenSquared() > Int<0>(0));
    #endif
  }

  Line Minus() const {
    return Line(-dir, -c);
  }

  P<T> KanonDir() const {
    auto g = Gcd(Abs(dir.x), Abs(dir.y));
    return P<T>(Podziel(dir.x, g), Podziel(dir.y, g));
  }

  void Draw() const {
    #ifdef LOCAL
    const ld aa = dir.x.ToLd();
    const ld bb = dir.y.ToLd();
    const ld cc = c.ToLd();
    const ld len = sqrt(aa * aa + bb * bb);
    auto Project = [len, aa, bb, cc](ld x, ld y) -> pair<ld, ld> {
      const ld dist = (aa * x + bb * y - cc) / len;
      x -= aa / len * dist;
      y -= bb / len * dist;
      return {x, y};
    };
    vector<pair<ld, ld>> punkty;
    for (int i = 0; i < 100; i++) {
      const ld x = rand() % (Box * 2 + 1) - Box;
      const ld y = rand() % (Box * 2 + 1) - Box;
      punkty.push_back(Project(x, y));
    }
    sort(punkty.begin(), punkty.end());
    for (int i = 1; i < (int) punkty.size(); i++) {
      debug() << "LINE " << punkty[i - 1].first << " " << punkty[i - 1].second
              << " " << punkty[i].first << " " << punkty[i].second;
    }
    for (const auto& p : punkty) {
      debug() << "LINE " << p.first << " " << p.second << " "
              << (p.first - aa / len) << " " << (p.second - bb / len);
    }
    #endif
  }
};

template <typename T, typename C>
auto Intersect(const Line<T, C>& a, const Line<T, C>& b)
    -> P<decltype((T() * C() - T() * C()) / (T() * T() - T() * T()))> {
  auto mianownik = a.dir * b.dir;
  #ifdef LOCAL
  assert(mianownik != Int<0>(0));
  #endif
  return P<decltype(T() * C() - T() * C())>(
      a.c * b.dir.y - b.c * a.dir.y, a.dir.x * b.c - b.dir.x * a.c)
          / mianownik;
}

template <typename T, typename C>
debug& operator<<(debug& deb, const Line<T, C>& l) {
  return deb << "Line{" << l.dir << ", " << l.c << "}";
}

// -------------------------------------------------------------------------- //
// -------------------------------------------------------------------------- //
// -------------------------------------------------------------------------- //

using MyLine = Line<Int<1000>, Int<1000 * 1000>>;

vector<MyLine> proste;

auto Wek(const MyLine& a, const MyLine& b) -> decltype(a.dir * b.dir) {
  return a.dir * b.dir;
}

bool Rown(const MyLine& a, const MyLine& b) {
  return Wek(a, b) == Int<0>(0);
}

bool Pokr(const MyLine& a, const MyLine& b) {
  return Rown(a, b) and a.dir.x * b.c == b.dir.x * a.c and
                        a.dir.y * b.c == b.dir.y * a.c;
}

bool Podobne(const MyLine& a, const MyLine& b) {
  return Rown(a, b) and a.dir.Above() == b.dir.Above();
}

auto Weaker(const MyLine& a, const MyLine& b)
    -> decltype(-a.c * Abs(b.dir.x) + b.c * Abs(a.dir.x)) {
  #ifdef LOCAL
  assert(Rown(a, b));
  #endif
  if (Abs(a.dir.x) > Abs(a.dir.y)) {
    return -a.c * Abs(b.dir.x) + b.c * Abs(a.dir.x);
  } else {
    return -a.c * Abs(b.dir.y) + b.c * Abs(a.dir.y);
  }
}

struct Comp {
  bool operator()(const MyLine& a, const MyLine& b) const {
    if (a.dir.Above() != b.dir.Above()) return a.dir.Above() > b.dir.Above();
    return Wek(a, b) > Int<0>(0);
  }
};

bool moj_empty, pek;
set<MyLine, Comp> S;
using Iter = set<MyLine, Comp>::iterator;

#define next next_do_not_use
#define prev prev_do_not_use
Iter Next(Iter it) { return (++it == S.end() ? S.begin() : it); }
Iter Prev(Iter it) { return (it == S.begin() ? --S.end() : --it); }

bool Hide(MyLine a, MyLine b, MyLine c) {
  if (Rown(a, b)) {
    if (Weaker(a, b.Minus()) < Int<0>(0)) moj_empty = true;
    return false;
  }
  if (Wek(a, b) < Int<0>(0)) swap(a, b);
  auto r = Intersect(a, b);
  auto v = r.x * c.dir.x + r.y * c.dir.y;
  auto vzero = ToFrac(c.c);
  if (Wek(a, c) >= Int<0>(0) and Wek(c, b) >= Int<0>(0) and v >= vzero) {
    return true;
  }
  if (Wek(a, c) < Int<0>(0) and Wek(c, b) < Int<0>(0)) {
    if (v < vzero) moj_empty = true;
    else if (v <= vzero) pek = true;
  }
  return false;
}

void Add(MyLine l) {
  if (moj_empty) return;
  Iter it = S.lower_bound(l);
  // Rownoległe.
  if (it != S.end() and Podobne(*it, l)) {
    if (Weaker(l, *it) >= Int<0>(0)) return;
    Iter del = it;
    it = Next(it);
    S.erase(del);
  }
  // *it > p
  if ((int) S.size() >= 2 and it == S.end()) it = S.begin();
  while ((int) S.size() >= 2 and Hide(l, *Next(it), *it)) {
    Iter del = it;
    it = Next(it);
    S.erase(del);
  }
  // *it < p
  if ((int) S.size() >= 2) it = Prev(it);
  while ((int) S.size() >= 2 and Hide(l, *Prev(it), *it)) {
    Iter del = it;
    it = Prev(it);
    S.erase(del);
  }
  if ((int) S.size() < 2 or !Hide(*it, *Next(it), l)) S.insert(l);
}

void CheckType() {
  if (moj_empty) throw ld(0);
  if ((int) S.size() <= 4) {
    vector<MyLine> res(S.begin(), S.end());
    if ((int) res.size() == 2 and Rown(res[0], res[1]) and
        Weaker(res[0], res[1].Minus()) < Int<0>(0)) {
      throw ld(0);
    }
    for (int i = 0; i < (int) res.size(); i++) {
      for (int j = 0; j < i; j++) {
        if (Pokr(res[i], res[j])) {
          throw ld(0);
        }
      }
    }
    if ((int) res.size() == 3 and pek) throw ld(0);
  }
}

void Rysuj() {
  #ifdef LOCAL
  debug() << imie(S);
  for (const MyLine& line : S) {
    line.Draw();
  }
  #endif
}

//int limit;

ld Pole() {
  vector<pair<ld, ld>> punkty;
  for (auto i = S.begin(); i != S.end(); ++i) {
    auto j = i;
    ++j;
    if (j == S.end()) j = S.begin();
    auto punkt = Intersect(*i, *j);
    punkty.emplace_back(punkt.x.ToLd(), punkt.y.ToLd());
  }
  #ifdef LOCAL
  for (auto& p : punkty) {
    debug() << "POINT " << p.first << " " << p.second;
  }
  #endif
  ld pole = 0;
  for (int i = 0; i < (int) punkty.size(); i++) {
    const int j = (i + 1) % punkty.size();
    pole += punkty[i].first * punkty[j].second
          - punkty[i].second * punkty[j].first;
  }
  return abs(pole) / 2;
}

void Przetnij() {
  for (MyLine& l : proste) {
    //if (limit-- == 0) break;
    debug() << imie(l);
    Add(l);
  }
  Rysuj();
  CheckType();
  throw Pole();
}

//// Is c hidden behind a and b?
//bool Hidden(const MyLine& a, const MyLine& b, const MyLine& c) {
//  //debug() << "Hidden(" imie(a) imie(b) imie(c) ")";
//  if (a.dir * b.dir < Int<0>(0)) return false;
//  if (a.dir * b.dir == Int<0>(0)) {
//    assert(a.KanonDir() * Int<1>(-1) == b.KanonDir());
//    if (-a.c <= b.c) {
//      throw ld(0);
//    }
//    return false;
//  }
//  auto p = Intersect(a, b);
//  return p % c.dir >= ToFrac(c.c);
//}
//
//// Is b hidden behind a?
//bool Hidden(const MyLine& a, const MyLine& b) {
//  return a.KanonDir() == b.KanonDir() and a.c >= b.c;
//}
//
//vector<MyLine> proste;
//
//int limit = 8;
//
//void Przetnij() {
//  sort(proste.begin(), proste.end(),
//       [&](const MyLine& a, const MyLine& b) -> bool {
//         if (a.dir.Above() != b.dir.Above()) {
//          return a.dir.Above();
//         }
//         auto v = a.dir * b.dir;
//         if (v == Int<0>(0)) return a.c < b.c;
//         return v > Int<0>(0);
//       });
//  debug() << "Posortowane:" imie(proste);
//
//  vector<MyLine> otoczka;
//  for (const MyLine& l : proste) {
//    if (limit-- == 0) break;
//    debug() << imie(otoczka) imie(l);
//    while (!otoczka.empty()) {
//      if (Hidden(l, otoczka.back())) {
//        otoczka.pop_back();
//        continue;
//      }
//      if ((int) otoczka.size() <= 1) {
//        break;
//      }
//      if (!Hidden(otoczka[(int) otoczka.size() - 2], l, otoczka.back())) {
//        break;
//      }
//      otoczka.pop_back();
//      debug() << "STEP" imie(otoczka);
//    }
//    otoczka.push_back(l);
//  }
//
//  #ifdef LOCAL
//  debug() << imie(otoczka);
//  for (const MyLine& line : otoczka) {
//    line.Draw();
//  }
//  #endif
//}

// -------------------------------------------------------------------------- //
// -------------------------------------------------------------------------- //
// -------------------------------------------------------------------------- //

using InputP = P<Int<500>>;

struct Mag {
  InputP a, b;
};

int n;
vector<Mag> magowie;

void OgarnijKierunek(const P<Int<1000>>& dir) {
  auto OgarnijMaga = [&dir](const Mag& m) -> Int<1000 * 1000> {
    return max(dir % m.a, dir % m.b);
  };
  assert(!magowie.empty());
  Int<1000 * 1000> c = OgarnijMaga(magowie[0]);
  for (const Mag& m : magowie) {
    Mini(c, OgarnijMaga(m));
  }
  proste.emplace_back(dir, c);
}

int main() {
  //limit = atoi(argv[1]);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  #ifdef LOCAL
  debug() << "FLIP_AXIS 1 -1";
  debug() << "COLOR 1 0.9 0.9";
  for (int x = -Box; x <= Box; x++) {
    debug() << "LINE " << x << " " << -Box << " " << x << " " << Box;
    debug() << "LINE " << -Box << " " << x << " " << Box << " " << x;
  }
  debug() << "COLOR 0.5 0.5 1";
  debug() << "LINE " << 0 << " " << -Box << " " << 0 << " " << Box;
  debug() << "LINE " << -Box << " " << 0 << " " << Box << " " << 0;
  debug() << "COLOR 0 0 0";
  #endif
  cin >> n;
  magowie.resize(n);
  vector<InputP> punkty;
  for (Mag& m : magowie) {
    cin >> m.a.x >> m.a.y >> m.b.x >> m.b.y;
    punkty.push_back(m.a);
    punkty.push_back(m.b);
    debug() << "COLOR 0 1 0";
    debug() << "POINT " << m.a.x << " " << m.a.y;
    debug() << "POINT " << m.b.x << " " << m.b.y;
    debug() << "LINE " << m.a.x << " " << m.a.y << " " << m.b.x << " " << m.b.y;
    debug() << "COLOR 0 0 0";
  }
  for (int i = 0; i < (int) punkty.size(); i++) {
    for (int j = 0; j < (int) punkty.size(); j++) {
      if (i != j) {
        OgarnijKierunek((punkty[i] - punkty[j]).Perp());
      }
    }
  }
  try {
    Przetnij();
  } catch (ld x) {
    cout << fixed << setprecision(20) << x << endl;
  }
  return 0;
}