Problem: Bob Bubblestrong just got a new job as security guard. Bob is now responsible for safety of a collection of warehouses, each containing the most valuable Bubble Cup assets - the high-quality bubbles. His task is to detect thieves inside the warehouses and call the police.

Looking from the sky, each warehouse has a shape of a convex polygon. Walls of no two warehouses intersect, and of course, none of the warehouses is built inside of another warehouse.

Little did the Bubble Cup bosses know how lazy Bob is and that he enjoys watching soap operas (he heard they are full of bubbles) from the coziness of his office. Instead of going from one warehouse to another to check if warehouses are secured, the plan Bob has is to monitor all the warehouses from the comfort of his office using the special X-ray goggles. The goggles have an infinite range, so a thief in any of the warehouses could easily be spotted.

However, the goggles promptly broke and the X-rays are now strong only enough to let Bob see through a single wall. Now, Bob would really appreciate if you could help him find out what is the total area inside of the warehouses monitored by the broken goggles, so that he could know how much area of the warehouses he needs to monitor in person.

Input

The first line contains one integer N (1 ≤ N ≤ 10^4) – the number of warehouses.

The next N lines describe the warehouses.

The first number of the line is integer c_i (3 ≤ c_i ≤ 10^4) – the number corners in the i^{th} warehouse, followed by c_i pairs of integers. The j^{th} pair is (x_j, y_j) – the coordinates of the j^{th} corner (|x_j|, |y_j| ≤ 3 * 10^4). The corners are listed in the clockwise order. The total number of corners in all the warehouses is at most 5 * 10^4.

Bob's office is positioned at the point with coordinates (0, 0). The office is not contained within any of the warehouses.

Output

Print a single line containing a single decimal number accurate to at least four decimal places – the total area of the warehouses Bob can monitor using the broken X-ray goggles.

Example

Input


5
4 1 1 1 3 3 3 3 1
4 4 3 6 2 6 0 4 0
6 -5 3 -4 4 -3 4 -2 3 -3 2 -4 2
3 0 -1 1 -3 -1 -3
4 1 -4 1 -6 -1 -6 -1 -4


Output


13.333333333333

Note

<image>

Areas monitored by the X-ray goggles are colored green and areas not monitored by the goggles are colored red.

The warehouses ABCD, IJK and LMNOPQ are completely monitored using the googles.

The warehouse EFGH is partially monitored using the goggles: part EFW is not monitored because to monitor each point inside it, the X-rays must go through two walls of warehouse ABCD.

The warehouse RUTS is not monitored from the Bob's office, because there are two walls of the warehouse IJK between Bob's office and each point in RUTS.

The total area monitored by the goggles is P = P_{ABCD} + P_{FGHW} + P_{IJK} + P_{LMNOPQ} = 4 + 3.333333333333 + 2 + 4 = 13.333333333333.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int w = 0, x = 0;
  char c = getchar();
  while (!isdigit(c)) w |= c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
  return w ? -x : x;
}
namespace star {
const int maxn = 1e5 + 10;
const double PI = acos(-1.), eps = 1e-12;
struct vec {
  double x, y;
  vec(double x = 0, double y = 0) : x(x), y(y) {}
  vec operator+(const vec &b) const { return vec(x + b.x, y + b.y); }
  vec operator-(const vec &b) const { return vec(x - b.x, y - b.y); }
  bool operator==(const vec &b) const { return x == b.x and y == b.y; }
  double operator*(const vec &b) const { return x * b.y - y * b.x; }
  inline double length() { return sqrt(x * x + y * y); }
  inline double dir() { return atan2(y, x); }
} e;
struct seg {
  vec a, b;
  seg() {}
  seg(vec a, vec b) : a(a), b(b) {}
  inline vec cross(vec e = star::e) const {
    if (e.x == 0) return vec(0, b.y - (b - a).y / (b - a).x * b.x);
    if (a == b) return a;
    double x = ((b.y - a.y) * b.x - (b.x - a.x) * b.y) /
               (b.y - a.y - (b.x - a.x) * e.y / e.x);
    return vec(x, x * e.y / e.x);
  }
} a[maxn];
struct cmp {
  bool operator()(const seg &a, const seg &b) const {
    return a.cross().length() < b.cross().length() or
           a.cross(e + eps).length() < b.cross(e + eps).length();
  }
};
multiset<seg, cmp> st;
pair<vec, int> c[maxn];
int n, tot;
multiset<seg, cmp>::iterator it[maxn];
double ans;
inline double S(vec A, vec B, vec C) {
  if (A == B or B == C or A == C) return 0;
  double a = (A - B).length(), b = (B - C).length(), c = (A - C).length(),
         p = (a + b + c) / 2;
  double ans = sqrt(p * (p - a) * (p - b) * (p - c));
  return isnan(ans) ? 0 : ans;
}
inline void work() {
  int m = read();
  static vec b[maxn];
  e = vec(-1, 0);
  for (int cnt, i = 1; i <= m; i++) {
    for (int j = cnt = read(); j; j--) b[j].x = read(), b[j].y = read();
    b[++cnt] = b[1];
    for (int i = 1; i < cnt; i++)
      if (b[i].y * b[i + 1].x != b[i + 1].y * b[i].x) {
        vec x = b[i], z = b[i + 1];
        a[++n] = seg(x, z);
        vec y = a[n].cross();
        if (y.x < 0 and x.y * z.y < 0) {
          if (x.dir() < z.dir()) swap(x, z);
          a[n] = seg(x, y), c[++tot] = make_pair(x, n << 1),
          c[++tot] = make_pair(y, n << 1 | 1);
          a[++n] = seg(y, z), c[++tot] = make_pair(y, n << 1),
          c[++tot] = make_pair(z, n << 1 | 1);
        } else {
          if (x.y == 0) x.y += z.y > 0 ? eps : -eps;
          if (z.y == 0) z.y += x.y > 0 ? eps : -eps;
          if (x.dir() > z.dir()) swap(x, z);
          a[n] = seg(x, z), c[++tot] = make_pair(x, n << 1),
          c[++tot] = make_pair(z, n << 1 | 1);
        }
      }
  }
  sort(c + 1, c + 1 + tot, [](pair<vec, int> a, pair<vec, int> b) {
    return a.first.y == 0 ? a.second & 1 ^ 1
           : b.first.y == 0
               ? b.second & 1
               : atan2(a.first.y, a.first.x) < atan2(b.first.y, b.first.x);
  });
  vec A, B, C, D;
  for (int i = 1; i < tot; i++) {
    if (st.size() >= 2) {
      A = (*st.begin()).cross(), B = (*++st.begin()).cross();
      e = c[i].first;
      C = (*st.begin()).cross(), D = (*++st.begin()).cross();
      ans += S(A, B, C) + S(B, C, D);
      if (isnan(ans)) {
        printf("%f %f  ", e.x, e.y);
        printf("%f %f\n", S(A, B, C), S(B, C, D));
        printf("%f %f  ", A.x, A.y);
        printf("%f %f  ", B.x, B.y);
        printf("%f %f  ", C.x, C.y);
        printf("%f %f\n", D.x, D.y);
        for (auto x : st) printf("%f %f %f %f|", x.a.x, x.a.y, x.b.x, x.b.y);
        return;
      }
    } else
      e = c[i].first;
    int x = c[i].second >> 1;
    if (c[i].second & 1 ^ 1)
      it[x] = st.insert(a[x]);
    else
      st.erase(it[x]);
  }
  printf("%.10f", ans);
}
}  // namespace star
signed main() {
  star::work();
  return 0;
}