Problem: The night after the graduation ceremony graduate students of German University in Cairo (GUC) are playing darts. As there's no real dart board available, the photographs of members of the GUC upper management are being used.

So, n rectangular photos are placed on the wall. They can overlap arbitrary and even coincide. The photos are not necessarily placed horizontally or vertically, they could also be rotated before being pinned to the wall.

The score of one dart throw is simply the number of photos the dart went through.

Fatma has made a throw but her score was not recorded. She only remembers that she did make it into at least one photo.

Assuming that the probability distribution of the throw is equal across the whole wall, what would be the expectation of Fatma's score?

Input

The first line of input contains integer n (1 ≤ n ≤ 500) — the number of photos on the wall. Then follow n lines describing the photos, each containing 8 single-space-separated integers (coordinates of 4 vertices): x1, y1, x2, y2, x3, y3, x4, y4. Each photo is a rectangle with a nonzero area. The coordinates are integers, not exceeding 104 by absolute value. The coordinates of the rectangle are given in either clockwise or counterclockwise order.

Output

Print the expected score of the throw. The answer will be accepted if it has absolute or relative error not exceeding 10 - 6.

Examples

Input

1
0 0 0 2 2 2 2 0


Output

1.0000000000


Input

1
-1 0 0 1 1 0 0 -1


Output

1.0000000000


Input

4
0 0 0 1 3 1 3 0
0 0 0 3 1 3 1 0
3 3 2 3 2 0 3 0
3 3 3 2 0 2 0 3


Output

1.5000000000


Input

2
-1 0 0 1 1 0 0 -1
0 0 1 1 2 0 1 -1


Output

1.1428571429

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
using namespace std;
namespace _c {
const double pi = acos(-1.0);
namespace min {
const int i8 = -128;
const int i16 = -32768;
const int i = -2147483647 - 1;
const long long l = -9223372036854775807LL - 1;
}  // namespace min
namespace max {
const int i8 = 127;
const int i16 = 32767;
const int i = 2147483647;
const long long l = 9223372036854775807LL;
}  // namespace max
}  // namespace _c
namespace _f {
template <typename T>
inline const T gcd(T m, T n) {
  while (n != 0) {
    T t = m % n;
    m = n;
    n = t;
  }
  return m;
}
template <typename T>
inline const T max(const T &a, const T &b) {
  return a > b ? a : b;
}
template <typename T>
inline const T min(const T &a, const T &b) {
  return a < b ? a : b;
}
template <typename T>
inline const T abs(const T &a) {
  return a > 0 ? a : -a;
}
template <typename T>
inline T pow(T a, T b) {
  T res = 1;
  while (b > 0) {
    if (b & 1) {
      res = res * a;
    }
    a = a * a;
    b >>= 1;
  }
  return res;
}
template <typename T>
inline T pow(T a, T b, const T &m) {
  a %= m;
  T res = 1;
  while (b > 0) {
    if (b & 1) {
      res = res * a % m;
    }
    a = a * a % m;
    b >>= 1;
  }
  return res % m;
}
}  // namespace _f
namespace io {
template <typename T>
inline void read(T &t) {
  register T res = 0, neg = 1;
  char g = getchar();
  for (; !isdigit(g); g = getchar()) {
    if (g == '-') {
      neg = -1;
    }
  }
  for (; isdigit(g); g = getchar()) {
    res = res * 10 + g - '0';
  }
  t = res * neg;
}
inline int in() {
  register int T;
  read(T);
  return T;
}
inline long long in_ll() {
  register long long T;
  read(T);
  return T;
}
}  // namespace io
const double eps = 1e-8;
int dcmp(double x) { return (x > eps) - (x < -eps); }
struct point {
  double x, y;
  point() {}
  point(double x, double y) : x(x), y(y) {}
  point operator-(const point &b) const { return point(x - b.x, y - b.y); }
  void input() { scanf("%lf%lf", &x, &y); }
};
double cross(point a, point b) { return a.x * b.y - a.y * b.x; }
double dot(point a, point b) { return a.x * b.x + a.y * b.y; }
struct polygon {
  point p[5];
  int sz;
  void init() { p[sz] = p[0]; }
} g[505];
pair<double, int> c[100000];
double segP(point a, point b, point c) {
  return dcmp(b.x - c.x) ? (a.x - b.x) / (c.x - b.x)
                         : (a.y - b.y) / (c.y - b.y);
}
double polyUnion(int n) {
  double sum = 0;
  for (int i = 0; i < n; ++i)
    for (int ii = 0; ii < g[i].sz; ++ii) {
      int tot = 0;
      c[tot++] = make_pair(0, 0);
      c[tot++] = make_pair(1, 0);
      for (int j = 0; j < n; ++j)
        if (i != j)
          for (int jj = 0; jj < g[j].sz; ++jj) {
            int d1 = dcmp(
                cross(g[i].p[ii + 1] - g[i].p[ii], g[j].p[jj] - g[i].p[ii]));
            int d2 = dcmp(cross(g[i].p[ii + 1] - g[i].p[ii],
                                g[j].p[jj + 1] - g[i].p[ii]));
            if (!d1 && !d2) {
              point t1 = g[j].p[jj + 1] - g[j].p[jj];
              point t2 = g[i].p[ii + 1] - g[i].p[ii];
              if (dcmp(dot(t1, t2)) > 0 && j < i) {
                c[tot++] =
                    make_pair(segP(g[j].p[jj], g[i].p[ii], g[i].p[ii + 1]), 1);
                c[tot++] = make_pair(
                    segP(g[j].p[jj + 1], g[i].p[ii], g[i].p[ii + 1]), -1);
              }
            } else if (d1 >= 0 && d2 < 0 || d1 < 0 && d2 >= 0) {
              double tc =
                  cross(g[j].p[jj + 1] - g[j].p[jj], g[i].p[ii] - g[j].p[jj]);
              double td = cross(g[j].p[jj + 1] - g[j].p[jj],
                                g[i].p[ii + 1] - g[j].p[jj]);
              if (d2 < 0)
                c[tot++] = make_pair(tc / (tc - td), 1);
              else
                c[tot++] = make_pair(tc / (tc - td), -1);
            }
          }
      sort(c, c + tot);
      double cur = _f::min(_f::max(c[0].first, 0.0), 1.0);
      int sgn = c[0].second;
      double s = 0;
      for (int j = 1; j < tot; ++j) {
        double nxt = _f::min(_f::max(c[j].first, 0.0), 1.0);
        if (!sgn) s += nxt - cur;
        sgn += c[j].second;
        cur = nxt;
      }
      sum += cross(g[i].p[ii], g[i].p[ii + 1]) * s;
    }
  return sum / 2;
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    double sum = 0;
    for (int i = 0; i < n; ++i) {
      g[i].sz = 4;
      for (int j = 0; j < g[i].sz; ++j) g[i].p[j].input();
      g[i].init();
      double tmp = 0;
      for (int j = 1; j <= 4; ++j) tmp += cross(g[i].p[j - 1], g[i].p[j]);
      sum += fabs(tmp);
      if (tmp < 0) swap(g[i].p[1], g[i].p[3]);
    }
    printf("%.10lf\n", sum * 0.5 / polyUnion(n));
  }
  return 0;
}