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
#include <bits/stdc++.h>
using namespace std;
double torad(double deg) { return deg / 180 * acos(-1.0); }
void get_coord(double r, double lat, double lng, double &x, double &y,
               double &z) {
  lat = torad(lat);
  lng = torad(lng);
  x = r * cos(lat) * cos(lng);
  y = r * cos(lat) * sin(lng);
  z = r * sin(lat);
}
int dcmp(double x) {
  if (fabs(x) < 1e-8) return 0;
  return x < 0 ? -1 : 1;
}
struct point {
  double x, y;
  point(double x = 0, double y = 0) : x(x), y(y) {}
  point operator-(const point &b) const { return point(x - b.x, y - b.y); }
  point operator+(const point &b) const { return point(x + b.x, y + b.y); }
  point operator*(const double &k) const { return point(x * k, y * k); }
  point operator/(const double &k) const { return point(x / k, y / k); }
  bool operator==(const point &b) const {
    return dcmp(x - b.x) == 0 && dcmp(y - b.y) == 0;
  }
  double ang() { return atan2(y, x); }
  double len() { return sqrt(x * x + y * y); }
  void input() { scanf("%lf%lf", &x, &y); }
};
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; }
point rotate(point a, double rad) {
  return point(a.x * cos(rad) - a.y * sin(rad),
               a.x * sin(rad) + a.y * cos(rad));
}
point normal(point a) {
  double L = a.len();
  return point(-a.y / L, a.x / L);
}
double point_to_line(point p, point a, point b) {
  point v1 = b - a, v2 = p - a;
  return fabs(cross(v1, v2)) / v1.len();
}
double point_to_segment(point p, point a, point b) {
  if (a == b) return (p - a).len();
  point v1 = b - a, v2 = p - a, v3 = p - b;
  if (dcmp(dot(v1, v2)) < 0) return v2.len();
  if (dcmp(dot(v1, v3)) > 0) return v3.len();
  return fabs(cross(v1, v2)) / v1.len();
}
point get_line_projection(point p, point a, point b) {
  point v = b - a;
  return a + v * (dot(v, p - a) / dot(v, v));
}
bool on_segment(point p, point a1, point a2) {
  if (p == a1 || p == a2) return 1;
  return dcmp(cross(a1 - p, a2 - p)) == 0 && dcmp(dot(a1 - p, a2 - p)) < 0;
}
bool parallel(point a1, point a2, point b1, point b2) {
  return dcmp(cross(a2 - a1, b2 - b1)) == 0;
}
bool segment_intersection(point a1, point a2, point b1, point b2) {
  if (on_segment(a1, b1, b2) || on_segment(a2, b1, b2)) return 1;
  if (on_segment(b1, a1, a2) || on_segment(b2, a1, a2)) return 1;
  double c1 = cross(a2 - a1, b1 - a1), c2 = cross(a2 - a1, b2 - a1);
  double c3 = cross(b2 - b1, a1 - b1), c4 = cross(b2 - b1, a2 - b1);
  return dcmp(c1) * dcmp(c2) < 0 && dcmp(c3) * dcmp(c4) < 0;
}
double polygon_area(point *p, int n) {
  double area = 0;
  for (int i = 1; i < n - 1; ++i) area += cross(p[i] - p[0], p[i + 1] - p[0]);
  return area / 2;
}
int point_in_polygon(point p, point *poly, int n) {
  int wn = 0;
  poly[n] = poly[0];
  for (int i = 0; i < n; ++i) {
    if (on_segment(p, poly[i], poly[i + 1])) return -1;
    int k = dcmp(cross(poly[i + 1] - poly[i], p - poly[i]));
    int d1 = dcmp(poly[i].y - p.y);
    int d2 = dcmp(poly[i + 1].y - p.y);
    if (k > 0 && d1 <= 0 && d2 > 0) wn++;
    if (k < 0 && d2 <= 0 && d1 > 0) wn--;
  }
  if (wn != 0) return 1;
  return 0;
}
point masscenter(point *p, int n) {
  point ret = point(0, 0);
  double sum = polygon_area(p, n);
  if (dcmp(sum) == 0) return ret;
  p[n] = p[0];
  for (int i = 0; i < n; ++i)
    ret = ret + (p[i] + p[i + 1]) * cross(p[i + 1], p[i]);
  return ret / sum / 6.0;
}
struct Line {
  point p, v;
  double ang;
  Line() {}
  Line(point p, point v) : p(p), v(v) { ang = atan2(v.y, v.x); }
  bool operator<(const Line &b) const { return ang < b.ang; }
};
bool onleft(Line L, point p) { return cross(L.v, p - L.p) > 0; }
point get_line_intersection(Line a, Line b) {
  point u = a.p - b.p;
  double t = cross(b.v, u) / cross(a.v, b.v);
  return a.p + a.v * t;
}
int half_plane_intersection(Line *L, int n, point *poly) {
  sort(L, L + n);
  int first, last;
  point *p = new point[n];
  Line *q = new Line[n];
  q[first = last = 0] = L[0];
  for (int i = 1; i < n; ++i) {
    while (first < last && !onleft(L[i], p[last - 1])) last--;
    while (first < last && !onleft(L[i], p[first])) first++;
    q[++last] = L[i];
    if (dcmp(cross(q[last].v, q[last - 1].v)) == 0) {
      last--;
      if (onleft(q[last], L[i].p)) q[last] = L[i];
    }
    if (first < last) p[last - 1] = get_line_intersection(q[last - 1], q[last]);
  }
  while (first < last && !onleft(q[first], p[last - 1])) last--;
  if (last - first <= 1) return 0;
  p[last] = get_line_intersection(q[last], q[first]);
  int m = 0;
  for (int i = first; i <= last; ++i) poly[m++] = p[i];
  return m;
}
double rotate_calipers(point *ch, int n) {
  int j = 1;
  double ret = 0;
  ch[n] = ch[0];
  for (int i = 0; i < n; ++i) {
    while (fabs(cross(ch[i + 1] - ch[i], ch[j + 1] - ch[i])) >
           fabs(cross(ch[i + 1] - ch[i], ch[j] - ch[i])))
      j = (j + 1) % n;
    ret = max(ret, max((ch[i] - ch[j]).len(), (ch[i + 1] - ch[j]).len()));
  }
  return ret;
}
struct polygon {
  point p[410];
  int sz;
  void input() {
    for (int i = 0; i < sz; ++i) p[i].input();
    if (dcmp(polygon_area(p, sz)) < 0) reverse(p, p + sz);
    p[sz] = p[0];
  }
  double polygon_area1() {
    double area = 0;
    for (int i = 1; i < sz - 1; ++i)
      area += cross(p[i] - p[0], p[i + 1] - p[0]);
    return area / 2;
  }
} g[550];
pair<double, int> C[100020];
double segP(point a, point b, point c) {
  if (dcmp(b.x - c.x)) return (a.x - b.x) / (c.x - b.x);
  return (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 d3 =
                  cross(g[j].p[jj + 1] - g[j].p[jj], g[i].p[ii] - g[j].p[jj]);
              double d4 = 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(d3 / (d3 - d4), 1);
              else
                C[tot++] = make_pair(d3 / (d3 - d4), -1);
            }
          }
      sort(C, C + tot);
      double cur = min(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 = min(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 fabs(sum) / 2;
}
int main() {
  int siz = 4, n, n2;
  double ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    g[i].sz = 4;
    g[i].input();
    ans += g[i].polygon_area1();
  }
  printf("%.10f\n", ans / polyUnion(n));
}
