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 = 500 + 10;
const long double eps = 1e-10;
inline int dblcmp(long double x) {
  if (fabs(x) < eps) return 0;
  return x > 0 ? 1 : -1;
}
int n, m;
struct Point {
  long double x, y;
  Point() {}
  Point(long double x, long double y) : x(x), y(y) {}
  void input() { cin >> x >> y; }
};
Point operator+(const Point& a, const Point& b) {
  return Point(a.x + b.x, a.y + b.y);
}
Point operator-(const Point& a, const Point& b) {
  return Point(a.x - b.x, a.y - b.y);
}
Point operator*(const Point& a, long double t) {
  return Point(a.x * t, a.y * t);
}
Point operator*(long double t, const Point& a) {
  return Point(a.x * t, a.y * t);
}
long double operator*(const Point& a, const Point& b) {
  return a.x * b.x + a.y * b.y;
}
long double operator%(const Point& a, const Point& b) {
  return a.x * b.y - a.y * b.x;
}
struct Line {
  Point p, v;
  Line() {}
  Line(Point p, Point v) : p(p), v(v) {}
} C[N * 4];
Point getIntersection(const Line& a, const Line& b) {
  long double t = b.v % (a.p - b.p) / (a.v % b.v);
  return a.p + a.v * t;
}
pair<Point, int> L[N * 4];
bool del[N * 4];
bool operator==(const Line& a, const Line& b) {
  return dblcmp(a.v % b.v) == 0 && dblcmp((b.p - a.p) % a.v) == 0;
}
struct cmp {
  Point p;
  cmp(const Point& p) : p(p) {}
  bool operator()(const pair<Point, int>& a, const pair<Point, int>& b) {
    return dblcmp((b.first - a.first) * p) == 1;
  }
};
long double ans, area;
void solve() {
  cin >> n;
  for (int i = (1); i <= (n); ++i) {
    Point a, b, c, d;
    a.input();
    b.input();
    c.input();
    d.input();
    if (dblcmp((b - a) % (c - a)) < 0) swap(a, d), swap(b, c);
    C[++m] = Line(a, b - a);
    C[++m] = Line(b, c - b);
    C[++m] = Line(c, d - c);
    C[++m] = Line(d, a - d);
    ans += a % b / 2 + b % c / 2 + c % d / 2 + d % a / 2;
  }
  for (int i = (1); i <= (m); ++i)
    if (!del[i]) {
      n = 0;
      for (int j = (1); j <= (m); ++j) {
        int t = dblcmp(C[j].v % C[i].v);
        if (t) {
          Point p = getIntersection(C[i], C[j]);
          if (dblcmp((p - C[j].p) * (C[j].p + C[j].v - p)) >= 0)
            L[++n] = make_pair(p, t);
        } else if (dblcmp((C[i].p - C[j].p) % C[i].v) == 0) {
          del[j] = 1;
          L[++n] = make_pair(C[j].p, 2);
          L[++n] = make_pair(C[j].p + C[j].v, -2);
        }
      }
      sort(L + 1, L + 1 + n, cmp(C[i].v));
      int cnt = 0, ct = 0;
      for (int j = (1); j <= (n - 1); ++j) {
        if (abs(L[j].second) > 1) {
          ct += L[j].second / 2;
        } else
          cnt += L[j].second;
        if (cnt > 0 && cnt == ct) {
          area += L[j].first % L[j + 1].first / 2;
        }
      }
    }
  ans /= area;
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(9);
  solve();
  return 0;
}