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 int maxn = 600;
const double eps = 1e-8;
inline int dcmp(double x) { return fabs(x) < eps ? 0 : (x > 0 ? 1 : -1); }
struct Point {
  double x, y;
  Point(double x = 0, double y = 0) : x(x), y(y) {}
  void scan() { scanf("%lf%lf", &x, &y); }
};
Point operator+(Point a, Point b) { return Point(a.x + b.x, a.y + b.y); }
Point operator-(Point a, Point b) { return Point(a.x - b.x, a.y - b.y); }
double operator^(Point a, Point b) { return a.x * b.x + a.y * b.y; }
double operator*(Point a, Point b) { return a.x * b.y - a.y * b.x; }
struct Rect {
  Point p[5];
  Point& operator[](int i) { return p[i]; }
  void scan() {
    int i;
    for (i = 0; i < 4; i++) p[i].scan();
    p[4] = p[0];
  }
  double area() {
    int i;
    double s = 0;
    for (i = 0; i < 4; i++) s += p[i] * p[i + 1];
    return s / 2;
  }
};
int n;
Rect r[maxn];
double ans = 0;
pair<double, int> pos[maxn * 8];
int ps;
inline double get_pos(Point a, Point b, Point p) {
  return dcmp(b.x - a.x) ? (p.x - a.x) / (b.x - a.x)
                         : (p.y - a.y) / (b.y - a.y);
}
double areaunion() {
  int i, j, ii, jj, d1, d2;
  double sum = 0, s1, s2, s0;
  for (i = 0; i < n; i++)
    for (ii = 0; ii < 4; ii++) {
      s0 = 0;
      ps = 0;
      pos[ps++] = make_pair(0, 0), pos[ps++] = make_pair(1, 0);
      for (j = 0; j < n; j++)
        if (i != j)
          for (jj = 0; jj < 4; jj++) {
            d1 = dcmp((r[i][ii + 1] - r[i][ii]) * (r[j][jj] - r[i][ii]));
            d2 = dcmp((r[i][ii + 1] - r[i][ii]) * (r[j][jj + 1] - r[i][ii]));
            if (!d1 && !d2) {
              if (dcmp((r[i][ii + 1] - r[i][ii]) ^ (r[j][jj + 1] - r[j][jj])) >
                      0 &&
                  i > j) {
                pos[ps++] =
                    make_pair(get_pos(r[i][ii], r[i][ii + 1], r[j][jj]), 1);
                pos[ps++] = make_pair(
                    get_pos(r[i][ii], r[i][ii + 1], r[j][jj + 1]), -1);
              }
            } else {
              s1 = (r[j][jj + 1] - r[j][jj]) * (r[i][ii] - r[j][jj]);
              s2 = (r[j][jj + 1] - r[j][jj]) * (r[i][ii + 1] - r[j][jj]);
              if (d1 < 0 && d2 >= 0)
                pos[ps++] = make_pair(s1 / (s1 - s2), -1);
              else if (d1 >= 0 && d2 < 0)
                pos[ps++] = make_pair(s1 / (s1 - s2), 1);
            }
          }
      sort(pos, pos + ps);
      double now, prv = min(max(pos[0].first, 0.0), 1.0);
      int cur = pos[0].second;
      for (j = 1; j < ps; j++) {
        now = min(max(pos[j].first, 0.0), 1.0);
        if (!cur) s0 += now - prv;
        cur += pos[j].second;
        prv = now;
      }
      sum += r[i][ii] * r[i][ii + 1] * s0;
    }
  return sum / 2;
}
int main() {
  int i, j;
  double s0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    r[i].scan();
    s0 = r[i].area();
    if (dcmp(s0) < 0) {
      reverse(r[i].p, r[i].p + 4);
      r[i][4] = r[i][0];
      s0 = -s0;
    }
    ans += s0;
  }
  ans /= areaunion();
  printf("%.9lf\n", ans);
  return 0;
}
