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
#include <bits/stdc++.h>
const double INF = 1e9 + 7;
const int N = 1e5 + 100;
using namespace std;
const double eps = 1e-8;
int cmp(double x) {
  if (fabs(x) < eps)
    return 0;
  else
    return x > 0 ? 1 : -1;
}
bool equal(double x, double y) { return cmp(x - y) == 0; }
struct Point {
  double x, y;
  Point(double _x = 0, double _y = 0) : x(_x), y(_y) {}
  friend Point operator+(const Point &A, const Point &B) {
    return Point(A.x + B.x, A.y + B.y);
  }
  friend Point operator-(const Point &A, const Point &B) {
    return Point(A.x - B.x, A.y - B.y);
  }
  friend double operator*(const Point &A, const Point &B) {
    return A.x * B.x + A.y * B.y;
  }
  friend double operator^(const Point &A, const Point &B) {
    return A.x * B.y - A.y * B.x;
  }
  friend Point operator*(const Point &A, const double &k) {
    return Point(A.x * k, A.y * k);
  }
  friend Point operator*(const double &k, const Point &A) {
    return Point(A.x * k, A.y * k);
  }
  void read() { scanf("%lf%lf", &x, &y); }
  void write() { printf("%lf %lf\n", x, y); }
};
Point V;
bool cmpP(pair<Point, int> A, pair<Point, int> B) {
  return cmp((B.first - A.first) * V) == 1;
}
struct Line {
  Point S, T;
  Line(Point _S = Point(0, 0), Point _T = Point(0, 0)) : S(_S), T(_T) {}
  friend Point Two_Line_Intersect(Line A, Line B) {
    if (cmp((A.T - A.S) ^ (B.T - B.S)) == 0) {
      if (cmp((A.S - B.S) ^ (A.S - B.T)) == 0)
        return Point(0, INF);
      else
        return Point(1, INF);
    } else {
      double k = ((B.T - A.T) ^ (A.S - A.T)) / ((B.T - B.S) ^ (A.S - A.T));
      return B.T + (B.S - B.T) * k;
    }
  }
  void write() {
    S.write();
    T.write();
    puts("");
  }
} L[N << 2];
int lcnt = 0;
int tot = 0;
pair<Point, int> P[6001];
bool Del[6001];
double ans = 0;
double area = 0;
int n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    Point A, B, C, D;
    A.read();
    B.read();
    C.read();
    D.read();
    if (cmp((B - A) ^ (C - A)) < 0) swap(A, D), swap(B, C);
    L[++lcnt] = Line(A, B);
    L[++lcnt] = Line(B, C);
    L[++lcnt] = Line(C, D);
    L[++lcnt] = Line(D, A);
    ans = ans + (A ^ B) / 2 + (B ^ C) / 2 + (C ^ D) / 2 + (D ^ A) / 2;
  }
  for (int i = 1; i <= lcnt; ++i) {
    if (Del[i] == 1) continue;
    int tot = 0;
    for (int j = 1; j <= lcnt; ++j) {
      int t = cmp((L[j].T - L[j].S) ^ (L[i].T - L[i].S));
      if (t != 0) {
        Point now = Two_Line_Intersect(L[i], L[j]);
        if (cmp((now - L[j].S) * (L[j].T - now)) >= 0)
          P[++tot] = make_pair(now, t);
      } else {
        if (cmp((L[i].S - L[j].S) ^ (L[i].T - L[i].S)) == 0) {
          Del[j] = 1;
          P[++tot] = make_pair(L[j].S, 2);
          P[++tot] = make_pair(L[j].T, -2);
        }
      }
    }
    V = L[i].T - L[i].S;
    stable_sort(P + 1, P + 1 + tot, cmpP);
    int cnt = 0;
    int ct = 0;
    for (int i = 1; i < tot; ++i) {
      if (abs(P[i].second) > 1) {
        ct += P[i].second / 2;
      } else
        cnt += P[i].second;
      if (cnt > 0 && cnt == ct) {
        area += (P[i].first ^ P[i + 1].first) / 2;
      }
    }
  }
  cout << fixed << setprecision(10) << ans / area;
  return 0;
}
