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;
struct point {
  long double x, y;
  point() {}
  point(long double inx, long double iny) {
    x = inx;
    y = iny;
  }
};
long double abs(point p) { return sqrt(p.x * p.x + p.y * p.y); }
long double prodvect(point p1, point p2) { return p1.x * p2.y - p1.y * p2.x; }
long double prodesc(point p1, point p2) { return p1.x * p2.x + p1.y * p2.y; }
point operator+(point p1, point p2) {
  p1.x += p2.x;
  p1.y += p2.y;
  return p1;
}
point operator-(point p1, point p2) {
  p1.x -= p2.x;
  p1.y -= p2.y;
  return p1;
}
point operator*(long double a, point p) {
  p.x *= a;
  p.y *= a;
  return p;
}
point operator*(point p, long double a) {
  p.x *= a;
  p.y *= a;
  return p;
}
point operator/(point p, long double a) {
  p.x /= a;
  p.y /= a;
  return p;
}
long double error = 0.00000001;
bool iguales(long double a, long double b) { return abs(a - b) < error; }
void orienta(vector<point> &v) {
  if (int(v.size()) < 3) return;
  int signo = prodvect(v[1] - v[0], v[2] - v[1]);
  if (signo < 0) reverse(v.begin(), v.end());
}
long double area(vector<point> &v) {
  long double a = 0;
  for (int i = 1; i < int(v.size()) - 1; i++)
    a += prodvect(v[i] - v[0], v[i + 1] - v[0]);
  return a / 2.0;
}
int ensegmento(point p, point p1, point q1) {
  point v1 = q1 - p1;
  point v2 = p - p1;
  if (not iguales(prodvect(v1, v2), 0)) return 0;
  if (prodesc(v1, v2) < error) return 2;
  if (prodesc(v1, v2) > abs(v1) * abs(v1) - error) return 0;
  return 1;
}
int hayinterseccion(point p1, point q1, point p2, point q2, point &intersec) {
  point v1 = q1 - p1;
  point v2 = q2 - p2;
  if (iguales(prodvect(v1, v2), 0)) return 0;
  intersec = p1 + (prodvect(p2 - p1, v2) / prodvect(v1, v2)) * v1;
  if (ensegmento(intersec, p2, q2) != 1) return 0;
  return ensegmento(intersec, p1, q1);
}
point leerpoint() {
  long double x, y;
  cin >> x >> y;
  return point(x, y);
}
vector<point> leerrect() {
  vector<point> v;
  for (int i = 0; i < 4; i++) v.push_back(leerpoint());
  return v;
}
void purgar(pair<point, point> &s1, pair<point, point> &s2) {
  if (iguales(s1.first.x, s1.second.x)) return;
  if (iguales(s2.first.x, s2.second.x)) return;
  if (not iguales(prodvect(s1.second - s1.first, s2.second - s2.first), 0))
    return;
  if (not iguales(prodvect(s1.second - s1.first, s2.second - s1.first), 0))
    return;
  if (s1.first.x <= s2.first.x) {
    if (s1.second.x <= s2.first.x) return;
    if (s2.second.x <= s1.second.x) {
      s2.first = s2.second;
      return;
    }
    s2.first = s1.second;
  } else if (s2.second.x <= s1.first.x) {
    return;
  } else if (s1.second.x <= s2.second.x) {
    s1.first = s1.second;
    return;
  } else {
    s2.second = s1.first;
  }
}
int numinter;
point inter[5000];
int val[5000];
int ind[5000];
bool comparaxx(int i1, int i2) { return inter[i1].x < inter[i2].x; }
void tratar(pair<point, point> &s, pair<point, point> &ss, int &up, int &down) {
  long double pv = prodvect(s.second - s.first, ss.second - ss.first);
  if (iguales(pv, 0)) return;
  point intersec;
  int hayintersec =
      hayinterseccion(s.first, s.second, ss.first, ss.second, intersec);
  int ensegfirst = ensegmento(ss.first, s.first, s.second);
  int ensegsecond = ensegmento(ss.second, s.first, s.second);
  if (hayintersec == 1) {
    if (pv > 0) {
      inter[numinter] = intersec;
      val[numinter] = 2;
      numinter++;
      inter[numinter] = intersec;
      val[numinter] = -2;
      numinter++;
    } else {
      inter[numinter] = intersec;
      val[numinter] = 1;
      numinter++;
      inter[numinter] = intersec;
      val[numinter] = -1;
      numinter++;
    }
  } else if (hayintersec == 2) {
    if (pv > 0) {
      up--;
      down--;
    } else {
      up++;
      down++;
    }
  } else if (ensegfirst == 1) {
    if (pv > 0) {
      inter[numinter] = ss.first;
      val[numinter] = 2;
      numinter++;
    } else {
      inter[numinter] = ss.first;
      val[numinter] = -1;
      numinter++;
    }
  } else if (ensegfirst == 2) {
    if (pv > 0)
      up--;
    else
      down++;
  } else if (ensegsecond == 1) {
    if (pv > 0) {
      inter[numinter] = ss.second;
      val[numinter] = -2;
      numinter++;
    } else {
      inter[numinter] = ss.second;
      val[numinter] = 1;
      numinter++;
    }
  } else if (ensegsecond == 2) {
    if (pv > 0)
      down--;
    else
      up++;
  }
}
int main() {
  cout.setf(ios::fixed);
  cout.precision(10);
  int n;
  cin >> n;
  vector<vector<point> > input;
  for (int i = 0; i < n; i++) input.push_back(leerrect());
  for (int i = 0; i < n; i++) orienta(input[i]);
  vector<pair<point, point> > segmento, segmentoini;
  for (int i = 0; i < n; i++) {
    vector<point> &v = input[i];
    for (int i = 0; i < 4; i++) {
      int nexti = (i + 1) % 4;
      pair<point, point> s(v[i], v[nexti]);
      segmentoini.push_back(s);
      if (not iguales(s.first.x, s.second.x)) {
        if (s.first.x > s.second.x) swap(s.first, s.second);
        segmento.push_back(s);
      }
    }
  }
  for (int i = 0; i < int(segmento.size()); i++)
    for (int j = 0; j < i; j++) purgar(segmento[i], segmento[j]);
  long double are = 0;
  for (int i = 0; i < int(segmento.size()); i++) {
    pair<point, point> &s = segmento[i];
    int up = 0;
    int down = 0;
    numinter = 0;
    inter[numinter] = s.first;
    val[numinter] = 0;
    numinter++;
    inter[numinter] = s.second;
    val[numinter] = 0;
    numinter++;
    for (int j = 0; j < int(segmentoini.size()); j++) {
      pair<point, point> &ss = segmentoini[j];
      tratar(s, ss, up, down);
    }
    for (int j = 0; j < numinter; j++) ind[j] = j;
    sort(ind, ind + numinter, comparaxx);
    for (int j = 0; j < numinter - 1; j++) {
      int i1 = ind[j];
      int i2 = ind[j + 1];
      point &po1 = inter[i1];
      point &po2 = inter[i2];
      int val2 = val[i2];
      long double y = (po1.y + po2.y) / 2.0;
      long double x = po2.x - po1.x;
      if (up == 0 and down > 0) are += y * x;
      if (up > 0 and down == 0) are -= y * x;
      if (val2 == 1)
        up++;
      else if (val2 == 2)
        up--;
      else if (val2 == -1)
        down++;
      else if (val2 == -2)
        down--;
    }
  }
  long double e = 0;
  for (int i = 0; i < n; i++) e += area(input[i]) / are;
  cout << e << endl;
}
