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;
int Sig(double a) { return a < -1e-8 ? -1 : (a > 1e-8); }
struct Point {
  double x, y;
  Point() {}
  Point(double x0, double y0) : x(x0), y(y0) {}
  void in() { scanf("%lf%lf", &x, &y); }
  void out() { printf("%.3f %.3f\n", x, y); }
  Point operator*(double t) { return Point(t * x, t * y); }
  double len() { return sqrt(x * x + y * y); }
  double operator*(Point pt) { return x * pt.y - y * pt.x; }
  double operator^(Point pt) { return pt.x * x + pt.y * y; }
  Point operator-(Point pt) { return Point(x - pt.x, y - pt.y); }
  Point operator+(Point pt) { return Point(x + pt.x, y + pt.y); }
  bool operator==(Point pt) {
    if (fabs(x - pt.x) < 1e-8 && fabs(y - pt.y) < 1e-8)
      return true;
    else
      return false;
  }
};
struct Line {
  Point p, q;
  Line() {}
  Line(Point p0, Point q0) : p(p0), q(q0) {}
};
Point Intersect(Line u, Line v) {
  Point ret = u.p;
  double t =
      ((u.p.x - v.p.x) * (v.p.y - v.q.y) - (u.p.y - v.p.y) * (v.p.x - v.q.x)) /
      ((u.p.x - u.q.x) * (v.p.y - v.q.y) - (u.p.y - u.q.y) * (v.p.x - v.q.x));
  ret.x += (u.q.x - u.p.x) * t;
  ret.y += (u.q.y - u.p.y) * t;
  return ret;
}
struct Polygon {
  Point p[1510];
  int n;
  bool getdir() {
    double sum = 0;
    for (int i = 0; i < n; i++) sum += p[i] * (p[(i + 1) % n]);
    if (Sig(sum) > 0) return 1;
    return 0;
  }
  double getarea() {
    double sum = 0;
    int i;
    for (i = 0; i < n; i++) sum += p[i] * p[(i + 1) % n];
    return fabs(sum) / 2;
  }
};
struct Polygon_set {
  vector<Polygon> p;
  int n;
  vector<pair<double, int> > e;
  void ins(Point s, Point t, Point X, int i) {
    double r = fabs(t.x - s.x) > 1e-8 ? (X.x - s.x) / (t.x - s.x)
                                      : (X.y - s.y) / (t.y - s.y);
    r = min(r, 1.0);
    r = max(r, 0.0);
    e.push_back(make_pair(r, i));
  }
  double polyareaunion() {
    double ans = 0.0;
    int c0, c1, c2, i, j, k, w;
    for (i = 0; i < p.size(); i++) {
      if (p[i].getdir() == 0) reverse(p[i].p, p[i].p + p[i].n);
    }
    for (i = 0; i < p.size(); i++) {
      for (k = 0; k < p[i].n; k++) {
        Point &s = p[i].p[k], &t = p[i].p[(k + 1) % p[i].n];
        if (!Sig(s * t)) continue;
        e.clear();
        e.push_back(make_pair(0.0, 1));
        e.push_back(make_pair(1.0, -1));
        for (j = 0; j < p.size(); j++)
          if (i != j) {
            for (w = 0; w < p[j].n; w++) {
              Point a = p[j].p[w], b = p[j].p[(w + 1) % p[j].n],
                    c = p[j].p[(w - 1 + p[j].n) % p[j].n];
              c0 = Sig((t - s) * (c - s));
              c1 = Sig((t - s) * (a - s));
              c2 = Sig((t - s) * (b - s));
              if (c1 * c2 < 0)
                ins(s, t, Intersect(Line(s, t), Line(a, b)), -c2);
              else if (!c1 && c0 * c2 < 0)
                ins(s, t, a, -c2);
              else if (!c1 && !c2) {
                int c3 = Sig((t - s) * (p[j].p[(w + 2) % p[j].n] - s));
                int dp = Sig((t - s) ^ (b - a));
                if (dp && c0)
                  ins(s, t, a, dp > 0 ? c0 * ((j > i) ^ (c0 < 0)) : -(c0 < 0));
                if (dp && c3)
                  ins(s, t, b, dp > 0 ? -c3 * ((j > i) ^ (c3 < 0)) : c3 < 0);
              }
            }
          }
        sort(e.begin(), e.end());
        int ct = 0;
        double tot = 0.0, last;
        int le = e.size();
        for (j = 0; j < le; j++) {
          if (ct == 1) tot += e[j].first - last;
          ct += e[j].second;
          last = e[j].first;
        }
        ans += (s * t) * tot;
      }
    }
    return fabs(ans) * 0.5;
  }
} pl;
int main() {
  int n;
  scanf("%d", &n);
  Polygon p;
  double ans = 0;
  for (int i = 0; i < n; i++) {
    p.n = 4;
    for (int i = 0; i < 4; i++) p.p[i].in();
    ans += p.getarea();
    pl.p.push_back(p);
  }
  printf("%.12f\n", ans / pl.polyareaunion());
  return 0;
}