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 maxn = 600, L = 4;
const double eps = 1e-8;
int T, n, tot = 0;
double sum;
inline int sig(double x) { return fabs(x) <= eps ? 0 : (x > eps ? 1 : -1); }
struct Tpoint {
  double x, y;
  Tpoint() {}
  Tpoint(double _x, double _y) { x = _x, y = _y; }
  inline Tpoint operator+(const Tpoint &b) const {
    return Tpoint(x + b.x, y + b.y);
  }
  inline Tpoint operator-(const Tpoint &b) const {
    return Tpoint(x - b.x, y - b.y);
  }
  inline double operator*(const Tpoint &b) const { return x * b.y - y * b.x; }
  inline double operator^(const Tpoint &b) const { return x * b.x + y * b.y; }
  inline Tpoint operator*(double a) const { return Tpoint(x * a, y * a); }
} p[maxn][L];
struct data {
  double rate;
  int bracket;
  data() {}
  data(double _r, int _b) { rate = _r, bracket = _b; }
  bool operator<(const data &b) const {
    return rate < b.rate || (sig(rate - b.rate) == 0 && bracket < b.bracket);
  }
} a[maxn * L];
inline int get() {
  int f = 0, v = 0;
  char ch;
  while (!isdigit(ch = getchar()))
    if (ch == '-') break;
  if (ch == '-')
    f = 1;
  else
    v = ch - 48;
  while (isdigit(ch = getchar())) v = v * 10 + ch - 48;
  if (f == 1)
    return -v;
  else
    return v;
}
inline double getd() {
  double d = 0, d2 = 0, d3 = 1;
  char ch;
  bool flag = 0;
  while (!isdigit(ch = getchar()))
    if (ch == '-') break;
  if (ch == '-')
    flag = true;
  else
    d = ch - 48;
  while (isdigit(ch = getchar())) d = d * 10 + ch - 48;
  if (ch == '.') {
    while (isdigit(ch = getchar())) d2 = d2 * 10 + ch - 48, d3 = d3 * 0.1;
    d += d3 * d2;
  }
  if (flag)
    return -d;
  else
    return d;
}
void init() {
  n = get();
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < L; j++) p[i][j].x = getd(), p[i][j].y = getd();
    for (int j = 1; j < L - 1; j++) {
      double area = (p[i][j] - p[i][j - 1]) * (p[i][j + 1] - p[i][j]);
      int tp = sig(area);
      if (tp == 0) continue;
      if (tp < 0) reverse(p[i], p[i] + L), area *= -1;
      sum += area;
      break;
    }
  }
}
Tpoint intersect(const Tpoint &a, const Tpoint &b, const Tpoint &c,
                 const Tpoint &d) {
  double ta = (b - c) * (a - c), tb = (a - d) * (b - d);
  Tpoint tp = (d - c) * (ta / (ta + tb)) + c;
  return tp;
}
void add(Tpoint s, Tpoint t, Tpoint p, int v) {
  double rate =
      sig(t.x - s.x) ? (p.x - s.x) / (t.x - s.x) : (p.y - s.y) / (t.y - s.y);
  a[++tot] = data(rate, v);
}
double work() {
  double ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int x = 0; x < L; x++) {
      a[tot = 1] = data(0, 1), a[++tot] = data(1, -1);
      Tpoint S = p[i][x], T = p[i][x + 1 == L ? 0 : x + 1], ST = T - S;
      for (int j = 1; j <= n; j++) {
        if (i == j) continue;
        for (int y = 0; y < L; y++) {
          int pre = y == 0 ? L - 1 : y - 1, suc = y + 1 == L ? 0 : y + 1;
          int p0 = sig(ST * (p[j][pre] - S)), p1 = sig(ST * (p[j][y] - S)),
              p2 = sig(ST * (p[j][suc] - S));
          if (p1 * p2 < 0)
            add(S, T, intersect(S, T, p[j][y], p[j][suc]), p2);
          else if (!p1 && p0 * p2 < 0)
            add(S, T, p[j][y], p2);
          else if (p1 == 0 && p2 == 0 && i > j &&
                   sig(ST ^ (p[j][suc] - p[j][y])) > 0)
            add(S, T, p[j][y], -1), add(S, T, p[j][suc], 1);
        }
      }
      sort(a + 1, a + 1 + tot);
      int cnt = 0;
      double Trate = 0, pre = 0;
      for (int j = 1; j <= tot; j++) {
        cnt += a[j].bracket;
        if (cnt == 0 && a[j].bracket == -1) Trate += a[j].rate - pre;
        pre = a[j].rate;
      }
      ans += S * T * Trate;
    }
  }
  return ans / 2.;
}
int main() {
  init();
  printf("%.10lf\n", sum / work());
  return 0;
}