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>
using namespace std;
const double eps = 1e-10;
inline int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') ch = getchar(), o = -1;
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o + 10000;
}
inline int jud(double x) {
  if (fabs(x) < eps) return 0;
  return x > 0 ? 1 : -1;
}
namespace Geometry {
struct Poi {
  double x, y;
  Poi() {}
  Poi(double x, double y) : x(x), y(y) {}
  inline void init() { scanf("%lf%lf", &x, &y); }
};
struct Lin {
  Poi p, v;
  Lin() {}
  Lin(Poi p, Poi v) : p(p), v(v) {}
};
inline Poi operator+(const Poi &A, const Poi &B) {
  return Poi(A.x + B.x, A.y + B.y);
}
inline Poi operator-(const Poi &A, const Poi &B) {
  return Poi(A.x - B.x, A.y - B.y);
}
inline Poi operator*(const Poi &A, double t) { return Poi(A.x * t, A.y * t); }
inline double operator*(const Poi &A, const Poi &B) {
  return A.x * B.x + A.y * B.y;
}
inline double operator^(const Poi &A, const Poi &B) {
  return A.x * B.y - A.y * B.x;
}
inline bool operator==(const Lin &A, const Lin &B) {
  return !(A.v ^ B.v) && !((B.p - A.p) ^ A.v);
}
inline Poi Inter(const Lin &A, const Lin &B) {
  double t = (B.v ^ (A.p - B.p)) / (A.v ^ B.v);
  return A.p + A.v * t;
}
}  // namespace Geometry
using namespace Geometry;
Lin A[(2010)];
pair<Poi, int> B[(2010)];
bool del[(2010)];
struct cmp {
  Poi p;
  cmp(const Poi &p) : p(p) {}
  inline bool operator()(const pair<Poi, int> &A, const pair<Poi, int> &B) {
    return jud((B.first - A.first) * p) == 1;
  }
};
int main() {
  int n, m = 0, k;
  double sum = 0, val = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    Poi a, b, c, d;
    a.init(), b.init(), c.init(), d.init();
    if (jud((b - a) ^ (c - a)) < 0) swap(a, d), swap(b, c);
    A[++m] = Lin(a, b - a);
    A[++m] = Lin(b, c - b);
    A[++m] = Lin(c, d - c);
    A[++m] = Lin(d, a - d);
    sum += (a ^ b) + (b ^ c) + (c ^ d) + (d ^ a);
  }
  sum /= 2;
  for (int i = 1; i <= m; i++) {
    if (del[i]) continue;
    k = 0;
    for (int j = 1; j <= m; j++) {
      int t = jud(A[j].v ^ A[i].v);
      if (t) {
        Poi p = Inter(A[i], A[j]);
        if (jud((p - A[j].p) * (A[j].p + A[j].v - p)) != -1)
          B[++k] = pair<Poi, int>(p, t);
      } else if (!jud((A[i].p - A[j].p) ^ A[i].v)) {
        del[j] = 1;
        B[++k] = pair<Poi, int>(A[j].p, 2),
        B[++k] = pair<Poi, int>(A[j].p + A[j].v, -2);
      }
    }
    sort(B + 1, B + 1 + k, cmp(A[i].v));
    for (int j = 1, in = 0, cov = 0; j < k; j++) {
      if (abs(B[j].second) == 2)
        cov += B[j].second / 2;
      else
        in += B[j].second;
      if (in && in == cov) val += (B[j].first ^ B[j + 1].first) / 2;
    }
  }
  printf("%.10f", sum / val);
  return 0;
}
