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;
template <class T>
inline void chkmin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline void chkmax(T &a, T b) {
  if (a < b) a = b;
}
const double pi = 4 * atan(1);
struct point {
  double x, y;
  point(double _x = 0, double _y = 0) : x(_x), y(_y) {}
  point operator+(point p) { return point(x + p.x, y + p.y); }
  point operator-(point p) { return point(x - p.x, y - p.y); }
  point operator*(double t) { return point(x * t, y * t); }
  point operator/(double t) { return point(x / t, y / t); }
};
inline int sign(double x) { return x < -1e-8 ? -1 : x > 1e-8; }
inline double dot(point a, point b) { return a.x * b.x + a.y * b.y; }
inline double multi(point a, point b) { return a.x * b.y - a.y * b.x; }
inline double norm(point a) { return dot(a, a); }
inline double abs(point a) { return sqrt(norm(a)); }
inline double arg(point a) { return atan2(a.y, a.x); }
inline double dist(point a, point b) { return abs(a - b); }
inline point polar(double len, double al) {
  return point(len * cos(al), len * sin(al));
}
inline double angle(point a, point b) {
  double al;
  al = dot(a, b) / abs(a) / abs(b);
  chkmax(al, -1.0);
  chkmin(al, 1.0);
  al = acos(al);
  return al;
}
double seg(point a, point b, point c) {
  if (sign(a.y - b.y) == 0)
    return (c.x - a.x) / (b.x - a.x);
  else
    return (c.y - a.y) / (b.y - a.y);
}
point p[555][5];
pair<double, int> b[5555];
int main() {
  int N, i, j, ii, jj, cnt, aa, bb, co;
  double tot, area, s1, s2, s, last, now;
  scanf("%d", &N);
  for (i = 0; i < N; i++)
    for (j = 0; j < 4; j++) scanf("%lf%lf", &p[i][j].x, &p[i][j].y);
  tot = 0;
  for (i = 0; i < N; i++) {
    area = 0;
    p[i][4] = p[i][0];
    for (j = 0; j < 4; j++) area += multi(p[i][j], p[i][j + 1]);
    if (area < 0) {
      reverse(p[i], p[i] + 4);
      p[i][4] = p[i][0];
      area = -area;
    }
    tot += area;
  }
  area = 0;
  for (i = 0; i < N; i++)
    for (ii = 0; ii < 4; ii++) {
      cnt = 0;
      b[cnt++] = make_pair(0.0, 0);
      b[cnt++] = make_pair(1.0, 0);
      for (j = 0; j < N; j++) {
        if (i == j) continue;
        for (jj = 0; jj < 4; jj++) {
          aa = sign(multi(p[i][ii + 1] - p[i][ii], p[j][jj] - p[i][ii]));
          bb = sign(multi(p[i][ii + 1] - p[i][ii], p[j][jj + 1] - p[i][ii]));
          if (aa == 0 && bb == 0) {
            if (dot(p[i][ii + 1] - p[i][ii], p[j][jj + 1] - p[j][jj]) > 0 &&
                j < i) {
              b[cnt++] = make_pair(seg(p[i][ii], p[i][ii + 1], p[j][jj]), 1);
              b[cnt++] =
                  make_pair(seg(p[i][ii], p[i][ii + 1], p[j][jj + 1]), -1);
            }
          } else if (aa < 0 && bb >= 0) {
            s1 = multi(p[i][ii] - p[j][jj], p[j][jj + 1] - p[j][jj]);
            s2 = s1 + multi(p[j][jj + 1] - p[j][jj], p[i][ii + 1] - p[j][jj]);
            b[cnt++] = make_pair(s1 / s2, -1);
          } else if (aa >= 0 && bb < 0) {
            s1 = multi(p[i][ii] - p[j][jj], p[j][jj + 1] - p[j][jj]);
            s2 = s1 + multi(p[j][jj + 1] - p[j][jj], p[i][ii + 1] - p[j][jj]);
            b[cnt++] = make_pair(s1 / s2, 1);
          }
        }
      }
      sort(b, b + cnt);
      s = 0;
      last = min(max(b[0].first, 0.0), 1.0);
      co = b[0].second;
      for (j = 1; j < cnt; ++j) {
        now = min(max(b[j].first, 0.0), 1.0);
        if (!co) s += now - last;
        co += b[j].second;
        last = now;
      }
      area += multi(p[i][ii], p[i][ii + 1]) * s;
    }
  area = fabs(area);
  printf("%.15lf\n", tot / area);
  return 0;
}