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;
pair<double, double> operator+(pair<double, double> a, pair<double, double> b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
pair<double, double> operator-(pair<double, double> a, pair<double, double> b) {
  return make_pair(a.first - b.first, a.second - b.second);
}
double operator*(pair<double, double> a, pair<double, double> b) {
  return a.first * b.second - b.first * a.second;
}
double operator^(pair<double, double> a, pair<double, double> b) {
  return a.first * b.first + a.second * b.second;
}
inline double cross(pair<double, double> o, pair<double, double> a,
                    pair<double, double> b) {
  return (a - o) * (b - o);
}
inline int cmp(double first) {
  if (fabs(first) < 1e-8) return 0;
  return first > 0 ? 1 : -1;
}
class Polygon {
 private:
  int i;
  double s;

 public:
  int n;
  pair<double, double> p[5];
  pair<double, double>& operator[](int idx) { return p[idx]; }
  void input() {
    for (i = 0; i < n; i++) scanf("%lf %lf", &p[i].first, &p[i].second);
    p[n] = p[0];
  }
  double Area() {
    for (s = 0, i = 0; i < n; i++) s += p[i] * p[i + 1];
    return s / 2;
  }
};
pair<double, int> s[502 * 5 * 2];
Polygon P[502];
double S, ts;
int N;
inline double seg(pair<double, double> o, pair<double, double> a,
                  pair<double, double> b) {
  if (cmp(b.first - a.first) == 0)
    return (o.second - a.second) / (b.second - a.second);
  return (o.first - a.first) / (b.first - a.first);
}
double PolygonUnion() {
  int M, c1, c2;
  double s1, s2, ret = 0;
  for (int i = 0; i < N; i++)
    for (int ii = 0; ii < P[i].n; ii++) {
      M = 0;
      s[M++] = make_pair(0.00, 0);
      s[M++] = make_pair(1.00, 0);
      for (int j = 0; j < N; j++)
        if (i != j)
          for (int jj = 0; jj < P[j].n; jj++) {
            c1 = cmp(cross(P[i][ii], P[i][ii + 1], P[j][jj]));
            c2 = cmp(cross(P[i][ii], P[i][ii + 1], P[j][jj + 1]));
            if (c1 == 0 && c2 == 0) {
              if (((P[i][ii + 1] - P[i][ii]) ^ (P[j][jj + 1] - P[j][jj])) > 0 &&
                  i > j) {
                s[M++] = make_pair(seg(P[j][jj], P[i][ii], P[i][ii + 1]), 1);
                s[M++] =
                    make_pair(seg(P[j][jj + 1], P[i][ii], P[i][ii + 1]), -1);
              }
            } else {
              s1 = cross(P[j][jj], P[j][jj + 1], P[i][ii]);
              s2 = cross(P[j][jj], P[j][jj + 1], P[i][ii + 1]);
              if (c1 >= 0 && c2 < 0)
                s[M++] = make_pair(s1 / (s1 - s2), 1);
              else if (c1 < 0 && c2 >= 0)
                s[M++] = make_pair(s1 / (s1 - s2), -1);
            }
          }
      sort(s, s + M);
      double pre = min(max(s[0].first, 0.0), 1.0), now;
      double sum = 0;
      int cov = s[0].second;
      for (int j = 1; j < M; j++) {
        now = min(max(s[j].first, 0.0), 1.0);
        if (!cov) sum += now - pre;
        cov += s[j].second;
        pre = now;
      }
      ret += P[i][ii] * P[i][ii + 1] * sum;
    }
  return ret / 2;
}
int main() {
  scanf("%d\n", &N);
  for (int i = 0; i < N; i++) {
    P[i].n = 4;
    P[i].input();
    ts = P[i].Area();
    if (cmp(ts < 0)) {
      reverse(P[i].p, P[i].p + P[i].n);
      P[i][P[i].n] = P[i][0];
      ts = -ts;
    }
    S += ts;
  }
  printf("%.9lf\n", S / PolygonUnion());
}