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>
#pragma GCC optimize("O3")
using namespace std;
const long double PI = acosl(-1);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
struct point {
  long double x, y;
  bool zin = false;
  long double val = 0;
  point() {}
  point(long double x, long double y) : x(x), y(y) {}
  long double kampas() {
    if (zin) return val;
    return atan2l(y, x);
  }
  void calc() {
    zin = true;
    val = atan2l(y, x);
  }
};
point operator+(point a, point b) { return point(a.x + b.x, a.y + b.y); }
point operator-(point a, point b) { return point(a.x - b.x, a.y - b.y); }
point operator*(point a, long double k) { return point(a.x * k, a.y * k); }
long double cross(point a, point b) { return a.x * b.y - a.y * b.x; }
long double f(long double alfa, long double beta, pair<point, point> ab) {
  point a = ab.first;
  point b = ab.second;
  point va(cosl(alfa), sinl(alfa));
  point vb(cosl(beta), sinl(beta));
  va = va * (cross(a, b) / cross(va, b - a));
  vb = vb * (cross(a, b) / cross(vb, b - a));
  return cross(va, vb) / 2;
}
long double calc(long double alfa, long double beta,
                 const vector<pair<point, point>>& A,
                 pair<point, point> mn = {point(1e10, 1e10), point(1e10, 1e10)},
                 pair<point, point> mn1 = {point(1e10, 1e10),
                                           point(1e10, 1e10)}) {
  if (A.empty()) {
    if (mn1.first.x < 1e9) {
      return f(alfa, beta, mn1) - f(alfa, beta, mn);
    } else
      return 0;
  }
  if (beta - alfa < 9e-9) return 0;
  vector<pair<point, point>> L, R;
  long double gamma = (alfa + beta) / 2;
  bool ok = true;
  point v(cos(gamma), sin(gamma));
  for (pair<point, point> i : A) {
    long double k1 = i.first.kampas();
    long double k2 = i.second.kampas();
    if (beta < k1 || k2 < alfa) continue;
    if (beta - alfa < PI)
      if (k1 < alfa && beta < k2) {
        long double k1 =
            cross(mn.first, mn.second) / cross(v, mn.second - mn.first);
        long double k2 =
            cross(mn1.first, mn1.second) / cross(v, mn1.second - mn1.first);
        long double d = cross(i.first, i.second) / cross(v, i.second - i.first);
        if (mn.first.x >= 1e9 || d <= k1) {
          mn1 = mn;
          mn = i;
        } else if (mn1.first.x >= 1e9 || d <= k2) {
          mn1 = i;
        }
        continue;
      }
    ok = false;
    if (k1 < gamma) L.push_back(i);
    if (k2 > gamma) R.push_back(i);
  }
  if (ok) return f(alfa, beta, mn1) - f(alfa, beta, mn);
  return calc(alfa, gamma, L, mn, mn1) + calc(gamma, beta, R, mn, mn1);
}
int sgn(long double x) {
  if (x < 0) return -1;
  if (x > 0) return 1;
  return 0;
}
int main() {
  cout << fixed << setprecision(3);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<point, point>> A;
  while (n--) {
    int k;
    cin >> k;
    point a0;
    cin >> a0.x >> a0.y;
    point aj = a0;
    for (int i = 1; i < k; i++) {
      point ai;
      cin >> ai.x >> ai.y;
      A.push_back({aj, ai});
      aj = ai;
    }
    A.push_back({aj, a0});
  }
  n = A.size();
  for (int i = 0; i < n; i++) {
    if (abs(A[i].first.y) < 0.5 || abs(A[i].second.y) < 0.5) continue;
    if ((A[i].first.y > 0) != (A[i].second.y > 0)) {
      long double k = -A[i].first.y / (A[i].second - A[i].first).y;
      point B = A[i].first + (A[i].second - A[i].first) * k;
      A.push_back({B, A[i].second});
      A[i].second = B;
    }
  }
  vector<pair<point, point>> A_;
  for (pair<point, point> b : A) {
    if (abs(b.first.kampas() - b.second.kampas()) > 1e-8) {
      A_.push_back(b);
    }
  }
  for (pair<point, point>& i : A_) {
    while (sgn(i.first.y) != sgn(i.second.y)) {
      if (abs(i.first.y) < abs(i.second.y)) {
        if (i.second.y > 0)
          i.first.y = 1e-11;
        else
          i.first.y = -1e-11;
      } else {
        if (i.first.y > 0)
          i.second.y = 1e-11;
        else
          i.second.y = -1e-11;
      }
    }
    if (i.first.kampas() > i.second.kampas()) swap(i.first, i.second);
    i.first.calc();
    i.second.calc();
  }
  cout << fixed << setprecision(20) << calc(-PI - 0.001, PI + 0.001, A_)
       << "\n";
}