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;
int const INF = (int)1e9 + 1e3;
long long const INFL = (long long)1e18 + 1e6;
mt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());
uniform_int_distribution<long long> ll_distr;
long long rnd(long long a, long long b) {
  return ll_distr(tw) % (b - a + 1) + a;
}
double sqr(double num) { return num * num; }
struct point {
  int x, y;
  point(int _x, int _y) : x(_x), y(_y) {}
  point operator+(point const& other) const {
    return point(x + other.x, y + other.y);
  }
  point operator-(point const& other) const {
    return point(x - other.x, y - other.y);
  }
  long long len2() const { return (long long)x * x + (long long)y * y; }
};
ostream& operator<<(ostream& o, point const& p) {
  o << "(" << p.x << ", " << p.y << ")";
  return o;
}
long long cross(point const& p1, point const& p2) {
  return p1.x * p2.y - p1.y * p2.x;
}
bool operator<(point const& p1, point const& p2) {
  bool fl1 = p1.y > 0 || (p1.y == 0 && p1.x > 0);
  bool fl2 = p2.y > 0 || (p2.y == 0 && p2.x > 0);
  if (fl1 != fl2) {
    return fl1 < fl2;
  }
  long long tmp = cross(p1, p2);
  if (tmp) {
    return tmp > 0;
  }
  return p1.len2() < p2.len2();
}
struct line {
  int a, b, c;
  line() : a(0), b(0), c(0) {}
  line(point const& p1, point const& p2) {
    a = p2.y - p1.y;
    b = p1.x - p2.x;
    c = -(p1.x * a + p1.y * b);
    assert(abs(a * p2.x + b * p2.y + c) < 1e-5);
  }
};
line cur_dir;
vector<line> segs;
double dist_intersection(line const& l1, line const& l2) {
  long long d = (long long)l1.a * l2.b - (long long)l1.b * l2.a;
  long long d1 = -(long long)l1.c * l2.b + (long long)l1.b * l2.c;
  long long d2 = -(long long)l1.a * l2.c + (long long)l1.c * l2.a;
  return sqr(d1 / (double)d) + sqr(d2 / (double)d);
}
struct segs_cmp {
  bool operator()(int a, int b) {
    if (a == b) {
      return false;
    }
    return dist_intersection(segs[a], cur_dir) <
           dist_intersection(segs[b], cur_dir);
  }
};
struct point_d {
  double x, y;
  point_d(double _x, double _y) : x(_x), y(_y) {}
  point_d(point p) : x(p.x), y(p.y) {}
};
double cross(point_d const& p1, point_d const& p2) {
  return p1.x * p2.y - p1.y * p2.x;
}
point_d intersection(line const& l1, line const& l2) {
  long long d = (long long)l1.a * l2.b - (long long)l1.b * l2.a;
  long long d1 = -(long long)l1.c * l2.b + (long long)l1.b * l2.c;
  long long d2 = -(long long)l1.a * l2.c + (long long)l1.c * l2.a;
  return point_d(d1 / (double)d, d2 / (double)d);
}
void solve() {
  int n;
  cin >> n;
  vector<vector<point>> polys;
  vector<pair<vector<point>, vector<point>>> parts;
  vector<tuple<point, int, int>> actions;
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    polys.push_back({});
    for (int j = 0; j < k; ++j) {
      int x, y;
      cin >> x >> y;
      polys[i].push_back({x, y});
    }
    reverse(polys[i].begin(), polys[i].end());
    int ind = 0;
    for (int j = 0; j < k; ++j) {
      if (cross(polys[i][ind], polys[i][j]) > 0) {
        ind = j;
      }
    }
    rotate(polys[i].begin(), polys[i].begin() + ind, polys[i].end());
    ind = 0;
    for (int j = 0; j < k; ++j) {
      if (cross(polys[i][ind], polys[i][j]) < 0) {
        ind = j;
      }
    }
    parts.push_back(
        {vector<point>(polys[i].begin(), polys[i].begin() + ind + 1),
         vector<point>(polys[i].begin() + ind, polys[i].end())});
    parts[i].second.push_back(polys[i][0]);
    reverse(parts[i].first.begin(), parts[i].first.end());
    actions.push_back({polys[i][0], i, 1});
    actions.push_back({polys[i][ind], i, 0});
    segs.push_back(line(polys[i][0], polys[i][ind]));
  }
  sort(actions.begin(), actions.end());
  vector<int> last_t(n);
  for (auto [p, ind, t] : actions) {
    last_t[ind] = t;
  }
  cur_dir = line(point(0, 0), get<0>(actions[0]));
  set<int, segs_cmp> have;
  for (int i = 0; i < n; ++i) {
    if (last_t[i] == 0) {
      have.insert(i);
    }
  }
  vector<vector<pair<point, point>>> poly_angles(n);
  for (int i = 0; i < ((int)actions.size()); ++i) {
    auto [p, ind, t] = actions[i];
    cur_dir = line(point(0, 0), p);
    int prev = (i - 1 + ((int)actions.size())) % ((int)actions.size());
    if (((int)have.size())) {
      if (cross(get<0>(actions[prev]), p)) {
        poly_angles[*have.begin()].push_back({get<0>(actions[prev]), p});
      }
    }
    if (t == 0) {
      have.insert(ind);
    } else {
      have.erase(ind);
    }
  }
  double ans = 0;
  for (int i = 0; i < n; ++i) {
    int ind = 0;
    for (int j = 0; j < ((int)poly_angles[i].size()); ++j) {
      if (cross(poly_angles[i][ind].first, poly_angles[i][j].first) < 0) {
        ind = j;
      }
    }
    rotate(poly_angles[i].begin(), poly_angles[i].begin() + ind,
           poly_angles[i].end());
    auto calc = [&](vector<point> const& pl) {
      int cnt = 0;
      double ret = 0;
      for (int j = 0; j < ((int)poly_angles[i].size()); ++j) {
        auto [from, to] = poly_angles[i][j];
        while (cross(pl[cnt], from) > 0) {
          ++cnt;
        }
        if (cross(pl[cnt], to) < 0) {
          line cl(pl[cnt], pl[cnt - 1]);
          ret += cross(intersection(line(point(0, 0), from), cl),
                       intersection(line(point(0, 0), to), cl));
          continue;
        }
        if (cross(pl[cnt], from) < 0) {
          ret += cross(
              intersection(line(point(0, 0), from), line(pl[cnt], pl[cnt - 1])),
              pl[cnt]);
        }
        while (cnt < ((int)pl.size()) - 1 && cross(pl[cnt + 1], to) >= 0) {
          ret += cross(pl[cnt], pl[cnt + 1]);
          ++cnt;
        }
        if (cnt < ((int)pl.size()) - 1) {
          ret += cross(pl[cnt], intersection(line(point(0, 0), to),
                                             line(pl[cnt], pl[cnt + 1])));
        }
      }
      return ret;
    };
    ans += calc(parts[i].second);
    ans -= calc(parts[i].first);
  }
  cout << ans / 2 << "\n";
}
int main() {
  cout << setprecision(15) << fixed;
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int test_count = 1;
  for (int test = 1; test <= test_count; ++test) {
    solve();
  }
}