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 int N = 550;
struct PT {
  double x, y;
  PT(double a = 0, double b = 0) {
    x = a;
    y = b;
  }
  double operator*(PT p) { return x * p.y - y * p.x; }
  PT operator-(PT p) { return PT(x - p.x, y - p.y); }
  double operator/(PT p) { return x * p.x + y * p.y; }
  double dis() { return sqrt(x * x + y * y); }
  void init() { scanf("%lf%lf", &x, &y); }
};
double zo(double x) { return fabs(x) < 1e-8 ? 0 : x; }
struct PY {
  int n;
  PT pt[5];
  PT &operator[](int x) { return pt[x]; }
  void init() {
    n = 4;
    for (int i = 0; i < n; i++) pt[i].init();
  }
  double area() {
    double ans = pt[n - 1] * pt[0];
    for (int i = 0; i < n - 1; ++i) ans += pt[i] * pt[i + 1];
    if (ans < 0) {
      for (int i = 0, j = n - 1; i < j; i++, j--) swap(pt[i], pt[j]);
      ans = -ans;
    }
    return ans;
  }
} py[N];
pair<double, int> pr[N * N * 2];
double segP(PT a, PT b, PT c) {
  if (zo(a.x - b.x) == 0) return (c.y - a.y) / (b.y - a.y);
  return (c.x - a.x) / (b.x - a.x);
}
double plyUnion(int n) {
  for (int i = 0; i < n; ++i) py[i][py[i].n] = py[i][0];
  double sum = 0;
  for (int i = 0; i < n; ++i) {
    for (int ii = 0; ii < py[i].n; ++ii) {
      PT &a = py[i][ii], &b = py[i][ii + 1];
      int id = 0;
      pr[++id] = make_pair(0, 0);
      pr[++id] = make_pair(1, 0);
      for (int j = 0; j < n; ++j) {
        if (i == j) continue;
        for (int jj = 0; jj < py[j].n; ++jj) {
          PT &c = py[j][jj], &d = py[j][jj + 1];
          double tc = zo((c - a) * (b - a));
          double td = zo((d - a) * (b - a));
          if (0 == tc && 0 == td) {
            if ((c - d) / (a - b) > 0 && j < i) {
              pr[++id] = make_pair(segP(a, b, c), 1);
              pr[++id] = make_pair(segP(a, b, d), -1);
            }
          } else if ((tc > 0 || td > 0) && tc * td <= 0) {
            int t = (tc > 0 ? -1 : 1);
            double acd = (a - c) * (d - c);
            double bcd = (b - c) * (d - c);
            pr[++id] = make_pair(acd / (acd - bcd), t);
          }
        }
      }
      sort(pr + 1, pr + id + 1);
      double lst = min(max(pr[1].first, 0.0), 1.0), now;
      int t = pr[1].second;
      double s = 0;
      for (int j = 2; j <= id; j++) {
        now = min(max(pr[j].first, 0.0), 1.0);
        if (t == 0) s += now - lst;
        t += pr[j].second;
        lst = now;
      }
      sum += (a * b) * s;
    }
  }
  return sum;
}
int main() {
  int n;
  scanf("%d", &n);
  double sum = 0;
  for (int i = 0; i < n; i++) {
    py[i].init();
    sum += py[i].area();
  }
  printf("%.9lf\n", sum / plyUnion(n));
  return 0;
}