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 comment(linker, "/STACK:102400000,102400000")
template <class T>
inline void gmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline void gmin(T &a, T b) {
  if (b < a) a = b;
}
using namespace std;
const int N = 500 + 10, M = 2e6 + 10, Z = 1e9 + 7, maxint = 2147483647,
          ms1 = 16843009, ms31 = 522133279, ms63 = 1061109567,
          ms127 = 2139062143;
const double PI = acos(-1.0), eps = 1e-8;
void fre() {
  freopen("/Users/luras/Desktop/in.txt", "r", stdin);
  freopen("/Users/luras/Desktop/out.txt", "w", stdout);
}
const int INF = 1e9;
int casenum, casei;
const double inf = 1e18;
inline double sqr(double x) { return x * x; }
inline int sgn(double x) { return x < -eps ? -1 : (x > eps); }
inline double fix(double x) { return sgn(x) == 0 ? 0 : x; }
struct point {
  double x, y;
  point(double x = 0, double y = 0) : x(x), y(y) {}
  bool operator<(const point &rhs) const {
    return sgn(x - rhs.x) < 0 || (sgn(x - rhs.x) == 0 && sgn(y - rhs.y) < 0);
  }
  bool operator==(const point &rhs) const {
    return sgn(x - rhs.x) == 0 && sgn(y - rhs.y) == 0;
  }
  point operator+(const point &rhs) const {
    return point(x + rhs.x, y + rhs.y);
  }
  point operator-(const point &rhs) const {
    return point(x - rhs.x, y - rhs.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); }
  double dot(const point &rhs) const { return x * rhs.x + y * rhs.y; }
  double det(const point &rhs) const { return x * rhs.y - y * rhs.x; }
  double norm2() const { return x * x + y * y; }
  double norm() const { return hypot(x, y); }
};
std::vector<point> polygon[N];
std::vector<point> convex_hull(std::vector<point> u) {
  std::sort(u.begin(), u.end());
  u.erase(std::unique(u.begin(), u.end()), u.end());
  if (u.size() < 3u) return u;
  std::vector<point> ret;
  for (size_t i = 0, o = 1, m = 1; ~i; i += o) {
    while (ret.size() > m) {
      point A = ret.back() - ret[ret.size() - 2];
      point B = ret.back() - u[i];
      if (sgn(A.det(B)) < 0) break;
      ret.pop_back();
    }
    ret.push_back(u[i]);
    if (i + 1 == u.size()) m = ret.size(), o = -1;
  }
  ret.pop_back();
  return ret;
}
inline double rati(const point &A, const point &B, const point &O) {
  if (sgn(A.x - B.x) == 0)
    return (O.y - A.y) / (B.y - A.y);
  else
    return (O.x - A.x) / (B.x - A.x);
}
double polygon_union(std::vector<point> poly[], int n) {
  double ret = 0;
  for (int i = 0; i < n; ++i) {
    for (size_t v = 0; v < poly[i].size(); ++v) {
      point A = poly[i][v], B = poly[i][(v + 1) % poly[i].size()];
      std::vector<std::pair<double, int> > segs;
      segs.push_back(std::make_pair(0.0, 0));
      segs.push_back(std::make_pair(1.0, 0));
      for (int j = 0; j < n; ++j)
        if (i != j) {
          for (size_t u = 0; u < poly[j].size(); ++u) {
            point C = poly[j][u], D = poly[j][(u + 1) % poly[j].size()];
            int sc = sgn((B - A).det(C - A)), sd = sgn((B - A).det(D - A));
            if (sc == 0 && sd == 0) {
              if (sgn((B - A).dot(D - C)) > 0 && i > j) {
                segs.push_back(std::make_pair(rati(A, B, C), +1));
                segs.push_back(std::make_pair(rati(A, B, D), -1));
              }
            } else {
              double sa = (D - C).det(A - C), sb = (D - C).det(B - C);
              if (sc >= 0 && sd < 0)
                segs.push_back(std::make_pair(sa / (sa - sb), 1));
              else if (sc < 0 && sd >= 0)
                segs.push_back(std::make_pair(sa / (sa - sb), -1));
            }
          }
        }
      std::sort(segs.begin(), segs.end());
      double pre = std::min(std::max(segs[0].first, 0.0), 1.0), now, sum = 0;
      int cnt = segs[0].second;
      for (size_t j = 1; j < segs.size(); ++j) {
        now = std::min(std::max(segs[j].first, 0.0), 1.0);
        if (!cnt) sum += now - pre;
        cnt += segs[j].second;
        pre = now;
      }
      ret += A.det(B) * sum;
    }
  }
  return ret / 2;
}
int n;
double h, f;
void run() {
  double x, y, th, ret = 0, sum = 0;
  for (int i = 0; i < n; ++i) {
    double l, r;
    point rect[4];
    for (int j = 0; j < 4; j++) scanf("%lf%lf", &rect[j].x, &rect[j].y);
    polygon[i].clear();
    for (int j = 0; j < 4; ++j) {
      polygon[i].push_back(rect[j]);
    }
    polygon[i] = convex_hull(polygon[i]);
    sum += (rect[1] - rect[0]).norm() * (rect[1] - rect[2]).norm();
  }
  ret = polygon_union(polygon, n);
  printf("%.10f\n", sum / ret);
}
int main() {
  while (~scanf("%d", &n)) {
    run();
  }
  return 0;
}