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 double EPS = 1E-7;
struct point {
  double x;
  double y;
  int id;
  point(double xx = 0, double yy = 0, int idd = 0) {
    x = xx;
    y = yy;
    id = idd;
  }
} O, rec[600][7], A, B;
double sqr(double x) { return x * x; }
point operator*(const point &a, const double b) {
  return point(a.x * b, a.y * b);
}
point operator/(const point &a, const double b) {
  return point(a.x / b, a.y / b);
}
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);
}
double operator^(const point &a, const point &b) {
  return a.x * b.x + a.y * b.y;
}
double operator*(const point &a, const point &b) {
  return a.x * b.y - a.y * b.x;
}
double dis(point &a, point &b) { return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y)); }
point j_d(point &a, point &b, point &c, point &d) {
  double s1, s2;
  point t;
  s1 = (c - a) * (b - a);
  s2 = (b - a) * (d - a);
  t.x = (c.x * s2 + d.x * s1) / (s1 + s2);
  t.y = (c.y * s2 + d.y * s1) / (s1 + s2);
  return t;
}
struct EV {
  int de;
  double cc;
  EV(point a = point(0, 0), int delta = 0) {
    cc = dis(a, A) / dis(A, B);
    if (((a - A) ^ (B - A)) < 0) cc = -cc;
    de = delta;
  }
} ev[4000];
bool operator<(const EV &a, const EV &b) { return a.cc < b.cc; }
int n;
int main() {
  scanf("%d", &n);
  double an = 0, ans = 0;
  for (int i = (1); i <= (n); i++) {
    for (int ii = (1); ii <= (4); ii++)
      scanf("%lf%lf", &rec[i][ii].x, &rec[i][ii].y);
    double t = (rec[i][2] - rec[i][1]) * (rec[i][3] - rec[i][1]);
    if (t < 0) {
      point trec[7];
      for (int ii = (1); ii <= (4); ii++) trec[ii] = rec[i][5 - ii];
      for (int ii = (1); ii <= (4); ii++) rec[i][ii] = trec[ii];
    }
    rec[i][0] = rec[i][4];
    rec[i][5] = rec[i][1];
    an += fabs(t);
  }
  O = rec[1][1];
  for (int i = (1); i <= (n); i++)
    for (int ii = (0); ii <= (5); ii++) rec[i][ii] = rec[i][ii] - O;
  O = point(0, 0);
  for (int i = (1); i <= (n); i++) {
    for (int ii = (1); ii <= (4); ii++) {
      double ss = rec[i][ii] * rec[i][ii + 1];
      int p = 0;
      A = rec[i][ii];
      B = rec[i][ii + 1];
      ev[++p] = EV(A, 0);
      ev[++p] = EV(B, 0);
      for (int j = (1); j <= (n); j++)
        if (i != j) {
          for (int jj = (1); jj <= (4); jj++) {
            double ta = (B - A) * (rec[j][jj] - A);
            double tb = (B - A) * (rec[j][jj + 1] - A);
            if (fabs(ta) + fabs(tb) < EPS && i > j) {
              if (((B - A) ^ (rec[j][jj + 1] - rec[j][jj])) > 0) {
                ev[++p] = EV(rec[j][jj], 1);
                ev[++p] = EV(rec[j][jj + 1], -1);
              }
            }
            point vv;
            if (abs((B - A) * (rec[j][jj + 1] - rec[j][jj])) > EPS)
              vv = j_d(A, B, rec[j][jj + 1], rec[j][jj]);
            if (ta > -EPS && tb < -EPS) ev[++p] = EV(vv, 1);
            if (ta < -EPS && tb > -EPS) ev[++p] = EV(vv, -1);
          }
        }
      sort(ev + 1, ev + p + 1);
      int o = 0;
      for (int j = (1); j <= (p); j++) {
        if (!(o += ev[j].de) && ev[j].cc > -EPS && ev[j].cc < 1 - EPS)
          ans += ss * (ev[j + 1].cc - ev[j].cc);
      }
    }
  }
  printf("%.12f", an / (ans / 2));
}