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>
using namespace std;
struct point {
  double x, y;
  point() {}
  point(double _x, double _y) {
    x = _x;
    y = _y;
  }
  void read() { scanf("%lf%lf", &x, &y); }
  void write() { printf("%lf %lf\n", x, y); }
};
bool dy(double x, double y) { return x > y + 1e-6; }
bool xy(double x, double y) { return x < y - 1e-6; }
bool dyd(double x, double y) { return x > y - 1e-6; }
bool xyd(double x, double y) { return x < y + 1e-6; }
bool dd(double x, double y) { return fabs(x - y) < 1e-6; }
inline int dblcmp(double x) {
  if (fabs(x) < 1e-6) return 0;
  return x > 0 ? 1 : -1;
}
point operator+(const point& lhs, const point& rhs) {
  return point(lhs.x + rhs.x, lhs.y + rhs.y);
}
point operator-(const point& lhs, const point& rhs) {
  return point(lhs.x - rhs.x, lhs.y - rhs.y);
}
point operator*(const long double& lhs, const point& rhs) {
  return point(lhs * rhs.x, lhs * rhs.y);
}
point operator*(const point& lhs, const long double& rhs) {
  return point(lhs.x * rhs, lhs.y * rhs);
}
point operator/(const point& lhs, const double& rhs) {
  return point(lhs.x / rhs, lhs.y / rhs);
}
double cross(point a, point b) { return a.x * b.y - a.y * b.x; }
double cross(point a, point b, point o) {
  double x1 = a.x - o.x, y1 = a.y - o.y, x2 = b.x - o.x, y2 = b.y - o.y;
  return x1 * y2 - x2 * y1;
}
double dis(point a, point b) {
  return (sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)));
}
double dot(point a, point b) { return a.x * b.x + a.y * b.y; }
double seg(point a, point b, point c) {
  if (dblcmp(a.y - b.y) == 0)
    return (c.x - a.x) / (b.x - a.x);
  else
    return (c.y - a.y) / (b.y - a.y);
}
int cmp(point a, point b) {
  if (dd(a.x, b.x)) return a.y < b.y;
  return a.x < b.x;
}
struct polygon {
  int n;
  point a[1000];
  point& operator[](const int x) { return a[x]; }
  void read() {
    for (int i = 0; i < n; ++i) scanf("%lf%lf", &a[i].x, &a[i].y);
  }
  double area() {
    double sum = cross(a[n - 1], a[0]);
    for (int i = 0; i < n - 1; ++i) sum += cross(a[i], a[i + 1]);
    return sum / 2;
  }
};
polygon po[2000];
point b[4010];
double polyunion(int n) {
  double sum = 0;
  for (int i = 0; i < n; ++i) po[i][po[i].n] = po[i][0];
  for (int i = 0; i < n; ++i)
    for (int ii = 0; ii < po[i].n; ++ii) {
      int tot = 0;
      b[tot++] = point(0.0, 0);
      b[tot++] = point(1.0, 0);
      for (int j = 0; j < n; ++j) {
        if (i == j) continue;
        for (int jj = 0; jj < po[j].n; ++jj) {
          int aa, bb;
          aa = dblcmp(cross(po[i][ii + 1], po[j][jj], po[i][ii]));
          bb = dblcmp(cross(po[i][ii + 1], po[j][jj + 1], po[i][ii]));
          if (aa == 0 && bb == 0) {
            if (dot(po[i][ii + 1] - po[i][ii], po[j][jj + 1] - po[j][jj]) > 0 &&
                j < i) {
              b[tot++] = point(seg(po[i][ii], po[i][ii + 1], po[j][jj]), 1);
              b[tot++] =
                  point(seg(po[i][ii], po[i][ii + 1], po[j][jj + 1]), -1);
            }
          } else if (aa < 0 && bb >= 0) {
            double s1 = cross(po[i][ii], po[j][jj + 1], po[j][jj]),
                   s2 = s1 + cross(po[j][jj + 1], po[i][ii + 1], po[j][jj]);
            b[tot++] = point(s1 / s2, -1);
          } else if (aa >= 0 && bb < 0) {
            double s1 = cross(po[i][ii], po[j][jj + 1], po[j][jj]),
                   s2 = s1 + cross(po[j][jj + 1], po[i][ii + 1], po[j][jj]);
            b[tot++] = point(s1 / s2, 1);
          }
        }
      }
      sort(b, b + tot, cmp);
      double last, now, s = 0, co;
      last = min(max(b[0].x, 0.0), 1.0);
      co = b[0].y;
      for (int j = 1; j < tot; ++j) {
        now = min(max(b[j].x, 0.0), 1.0);
        if (!co) s += now - last;
        co += b[j].y;
        last = now;
      }
      sum += cross(po[i][ii], po[i][ii + 1]) * s;
    }
  return sum / 2;
}
int n;
double sum;
int main() {
  scanf("%d", &n);
  sum = 0;
  for (int i = 0; i < n; i++) {
    po[i].n = 4;
    po[i].read();
    double area = po[i].area();
    if (area < 0) {
      for (int j = 0, k = po[i].n - 1; j < k; ++j, --k)
        swap(po[i][j], po[i][k]);
      area = -area;
    }
    sum += area;
  }
  printf("%.7lf\n", sum / polyunion(n));
  return 0;
}