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;
const double eps = 1e-10;
struct point {
  double x, y;
};
double cross(point a, point b);
double cross(point a, point b, point o);
struct polygon {
  int n;
  point a[5];
  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;
  }
} po[510];
point operator-(point a, point b) {
  point px;
  px.x = b.x - a.x;
  px.y = b.y - a.y;
  return px;
}
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 dot(point a, point b) { return a.x * b.x + a.y * b.y; }
int sign(double x) { return x < -eps ? -1 : x > eps; }
double seg(point a, point b, point c) {
  if (sign(a.y - b.y) == 0)
    return (c.x - a.x) / (b.x - a.x);
  else
    return (c.y - a.y) / (b.y - a.y);
}
pair<double, int> 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++] = make_pair(0.0, 0);
      b[tot++] = make_pair(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 = sign(cross(po[i][ii + 1], po[j][jj], po[i][ii]));
          bb = sign(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++] = make_pair(seg(po[i][ii], po[i][ii + 1], po[j][jj]), 1);
              b[tot++] =
                  make_pair(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++] = make_pair(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++] = make_pair(s1 / s2, 1);
          }
        }
      }
      sort(b, b + tot);
      double last, now, s = 0, co;
      last = min(max(b[0].first, 0.0), 1.0);
      co = b[0].second;
      for (int j = 1; j < tot; ++j) {
        now = min(max(b[j].first, 0.0), 1.0);
        if (!co) s += now - last;
        co += b[j].second;
        last = now;
      }
      sum += cross(po[i][ii], po[i][ii + 1]) * s;
    }
  return sum / 2;
}
int main() {
  double sum = 0, ar;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    po[i].n = 4;
    po[i].read();
    ar = po[i].area();
    if (ar < 0) {
      for (int j = 0, k = po[i].n - 1; j < k; ++j, --k)
        swap(po[i][j], po[i][k]);
      ar = -ar;
    }
    sum += ar;
  }
  printf("%.9lf\n", sum / polyunion(n));
  return 0;
}