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 inf = 0x3f3f3f3f;
const long long infLL = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-8;
int sgn(double x) { return x < -eps ? -1 : x > eps; }
bool zero(complex<double> v) { return !sgn(v.real()) && !sgn(v.imag()); }
double dot(complex<double> u, complex<double> v) {
  return u.real() * v.real() + u.imag() * v.imag();
}
double cross(complex<double> u, complex<double> v) {
  return u.real() * v.imag() - u.imag() * v.real();
}
complex<double> unit(complex<double> v) { return v / abs(v); }
complex<double> normal(complex<double> v) {
  return complex<double>(-v.imag(), v.real());
}
complex<double> rotate(complex<double> v, double a) {
  return v * polar(1.0, a);
}
complex<double> proj(complex<double> u, complex<double> v) {
  return v * dot(u, v) / norm(v);
}
complex<double> reflect(complex<double> u, complex<double> v) {
  return proj(u, v) * 2.0 - u;
}
double polygon_area(const vector<complex<double> > &g) {
  double res = 0;
  for (int i = 1; i < (int)g.size() - 1; ++i)
    res += cross(g[i] - g[0], g[i + 1] - g[0]);
  return res / 2;
}
void polygon_union(vector<complex<double> > g[], int n, double area[]) {
  for (int i = 0; i <= n; ++i) area[i] = 0;
  for (int u = 0; u < n; ++u)
    for (int i = 0; i < (int)g[u].size(); ++i) {
      vector<pair<double, int> > vec;
      complex<double> a = (i ? g[u][i - 1] : g[u].back()), b = g[u][i];
      for (int v = 0; v < n; ++v)
        if (v != u)
          for (int j = 0; j < (int)g[v].size(); ++j) {
            complex<double> c = (j ? g[v][j - 1] : g[v].back()), d = g[v][j];
            int c1 = sgn(cross(b - a, c - a)), c2 = sgn(cross(b - a, d - a)),
                d1 = sgn(dot(b - a, d - c));
            if (c1 || c2) {
              if ((c1 ^ c2) >= 0) continue;
              double s1 = cross(d - c, a - c), s2 = cross(d - c, b - c);
              double k = s1 / (s1 - s2);
              int t = (c1 >= 0 ? 1 : -1);
              vec.push_back(make_pair(k, t));
            } else if (u < v && d1 > 0) {
              double k;
              k = ((c - a) / (b - a)).real();
              vec.push_back(make_pair(k, 1));
              k = ((d - a) / (b - a)).real();
              vec.push_back(make_pair(k, -1));
            }
          }
      vec.push_back(make_pair(0.0, 0));
      vec.push_back(make_pair(1.0, 0));
      sort(vec.begin(), vec.end());
      double s = 0.5 * cross(a, b), p = min(max(vec[0].first, 0.0), 1.0);
      int k = vec[0].second;
      for (int j = 1; j < (int)vec.size(); ++j) {
        double q = min(max(vec[j].first, 0.0), 1.0);
        area[k] += s * (q - p);
        p = q;
        k += vec[j].second;
      }
    }
}
const int maxn = 500 + 5;
int n;
vector<complex<double> > g[maxn];
double area[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (4); ++j) {
      int x, y;
      scanf("%d%d", &x, &y);
      g[i].push_back(complex<double>(x, y));
    }
    double tmp = polygon_area(g[i]);
    if (sgn(tmp) < 0) reverse(g[i].begin(), g[i].end());
  }
  polygon_union(g, n, area);
  double res = 0;
  for (int i = (1); i <= (n); ++i) res += (area[i - 1] - area[i]) * i;
  printf("%.10f\n", res / area[0]);
  return 0;
}