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;
pair<double, double> operator-(pair<double, double> a, pair<double, double> b) {
  return {a.first - b.first, a.second - b.second};
}
pair<double, double> operator+(pair<double, double> a, pair<double, double> b) {
  return {a.first + b.first, a.second + b.second};
}
pair<double, double> operator*(pair<double, double> a, double b) {
  return {a.first * b, a.second * b};
}
pair<double, double> operator/(pair<double, double> a, double b) {
  return {a.first / b, a.second / b};
}
double cross(pair<double, double> a, pair<double, double> b) {
  return a.first * b.second - a.second * b.first;
}
double dot(pair<double, double> a, pair<double, double> b) {
  return a.first * b.first + a.second * b.second;
}
int part(pair<double, double> a) {
  if (a.second > 0 || (a.second == 0 && a.first > 0)) return 0;
  return 1;
}
pair<double, double> rot(pair<double, double> a, double ang) {
  return {a.first * cos(ang) - a.second * sin(ang),
          a.first * sin(ang) + a.second * cos(ang)};
}
struct line {
  pair<double, double> v;
  double c;
  line(pair<double, double> a, pair<double, double> b)
      : v(b - a), c(cross(v, a)) {}
  line(pair<pair<double, double>, pair<double, double>> a)
      : line(a.first, a.second) {}
  pair<double, double> sec(line b) {
    return (b.v * c - v * b.c) / cross(v, b.v);
  }
  double dot(pair<double, double> a) { return ::dot(v, a); }
};
const int N = 50050;
const double eps_ang = 1e-5;
pair<double, double> ray;
pair<pair<double, double>, pair<double, double>> s[N];
pair<double, double> sec(pair<double, double> ray,
                         pair<pair<double, double>, pair<double, double>> a) {
  return line(pair<double, double>(0, 0), ray).sec(line(a));
}
double abs(pair<double, double> a) {
  return sqrt(a.first * a.first + a.second * a.second);
}
pair<double, double> p[N];
struct cmp {
  bool operator()(pair<pair<double, double>, pair<double, double>> a,
                  pair<pair<double, double>, pair<double, double>> b) const {
    return abs(sec(ray, a)) < abs(sec(ray, b));
  }
};
set<pair<pair<double, double>, pair<double, double>>, cmp> all;
bool in[N];
void PRINT() {
  for (auto it : all) {
    printf("(%.0f %.0f) (%.0f %.0f)\n", it.first.first, it.first.second,
           it.second.first, it.second.second);
  }
}
int main() {
  int n, m = 0;
  scanf("%i", &n);
  while (n--) {
    int k;
    scanf("%i", &k);
    for (int i = 0; i < k; i++) {
      scanf("%lf %lf", &p[i].first, &p[i].second);
    }
    for (int i = 0; i < k; i++) {
      s[++m] = {p[i], p[(i + 1) % k]};
    }
  }
  vector<pair<pair<double, double>, int>> evs;
  for (int i = 1; i <= m; i++)
    if (cross(s[i].first, s[i].second) != 0) {
      evs.push_back({s[i].first, i});
      evs.push_back({s[i].second, i});
    }
  auto evcmp = [&](pair<pair<double, double>, int> a,
                   pair<pair<double, double>, int> b) {
    if (part(a.first) != part(b.first)) return part(a.first) < part(b.first);
    return cross(a.first, b.first) > 0;
  };
  sort(evs.begin(), evs.end(), evcmp);
  ray = rot({1, 0}, -eps_ang);
  pair<double, double> last = {1, 0};
  for (int i = 1; i <= m; i++)
    if (cross(s[i].first, s[i].second) != 0) {
      pair<double, double> A = s[i].first;
      pair<double, double> B = s[i].second;
      if (part(A) != part(B)) {
        if (part(A) == 0) swap(A, B);
        if (cross(A, B) > 0) {
          all.insert(s[i]);
          in[i] = true;
        }
      }
    }
  double ans = 0;
  for (int i = 0, j; i < evs.size(); i = j) {
    vector<int> add, del;
    for (j = i; j < evs.size() && !evcmp(evs[i], evs[j]); j++) {
      if (in[evs[j].second])
        del.push_back(evs[j].second);
      else
        add.push_back(evs[j].second);
    }
    ray = rot(evs[i].first, -eps_ang);
    if (all.size() >= 2) {
      ans -=
          abs(cross(sec(last, *all.begin()), sec(evs[i].first, *all.begin()))) /
          2;
      ans += abs(cross(sec(last, *next(all.begin())),
                       sec(evs[i].first, *next(all.begin())))) /
             2;
    }
    for (int z : del) {
      all.erase(s[z]);
      in[z] = false;
    }
    ray = rot(evs[i].first, eps_ang);
    for (int z : add) {
      all.insert(s[z]);
      in[z] = true;
    }
    last = evs[i].first;
  }
  if (all.size() >= 2) {
    ans -= abs(cross(sec(last, *all.begin()), sec({1, 0}, *all.begin()))) / 2;
    ans += abs(cross(sec(last, *next(all.begin())),
                     sec({1, 0}, *next(all.begin())))) /
           2;
  }
  printf("%.12f\n", ans);
  return 0;
}