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;
const int N = 5e4 + 8;
const long double eps = 1e-9;
const long double pi = acos(-1.0);
const long double inf = 1e6;
int cnt;
int segcnt = 0;
long double curang;
struct Point {
  long double x, y;
  long double corss(Point b) const { return x * b.y - b.x * y; }
  Point operator-(const Point& b) const { return (Point){x - b.x, y - b.y}; }
  long double len() { return sqrt(x * x + y * y); }
};
Point segcross(Point a, Point b, Point c, Point d, bool& ok) {
  long double u = (b - a).corss(c - a), v = (a - b).corss(d - b);
  if (fabs(u + v) < eps) {
    ok = 0;
    Point tem = {-1, -1};
    return tem;
  }
  ok = 1;
  return (Point){(c.x * v + d.x * u) / (u + v), (c.y * v + d.y * u) / (u + v)};
}
struct Seg {
  Point a, b;
  int id;
  bool operator<(const Seg& s) const {
    bool ok1, ok2;
    Point c = (Point){cos(curang), sin(curang)};
    Point o = (Point){0, 0};
    Point cr1 = segcross(a, b, o, c, ok1);
    Point cr2 = segcross(s.a, s.b, o, c, ok2);
    if (fabs(cr1.len() - cr2.len()) < eps) return id < s.id;
    return cr1.len() < cr2.len();
  }
};
vector<Point> pol[N];
long double ang[N];
vector<int> add[N], del[N];
Seg seg[N];
void add_seg(Point a, Point b) {
  long double anga = atan2l(a.y, a.x), angb = atan2l(b.y, b.x);
  if (fabs(anga - angb) < eps) return;
  if (anga > angb + eps) {
    swap(anga, angb);
    swap(a, b);
  }
  int pa = lower_bound(ang + 1, ang + 1 + cnt, anga) - ang;
  int pb = lower_bound(ang + 1, ang + 1 + cnt, angb) - ang;
  ++segcnt;
  seg[segcnt] = (Seg){a, b, segcnt};
  if (angb - anga > pi + eps) {
    if (fabs(anga + pi) > eps) {
      add[1].push_back(segcnt);
      del[pa].push_back(segcnt);
    }
    if (fabs(angb - pi) > eps) {
      add[pb].push_back(segcnt);
      del[cnt].push_back(segcnt);
    }
  } else {
    add[pa].push_back(segcnt);
    del[pb].push_back(segcnt);
  }
}
long double area(Point a, Point b, Point c, Point d) {
  long double res = 0;
  res += (b - a).corss(c - a);
  res += (c - a).corss(d - a);
  if (res < -eps) res = -res;
  return res * 0.5;
}
void solve() {
  set<Seg> st;
  long double ans = 0;
  curang = 0;
  for (int i = 1; i < cnt; ++i) {
    for (auto it : del[i]) st.erase(seg[it]);
    curang = (ang[i] + ang[i + 1]) / 2.0;
    for (auto it : add[i]) st.insert(seg[it]);
    if ((int)st.size() >= 2) {
      Seg s1, s2;
      auto it = st.begin();
      s1 = (*it);
      ++it;
      s2 = (*it);
      Point c1 = (Point){inf * cos(ang[i]), inf * sin(ang[i])};
      Point c2 = (Point){inf * cos(ang[i + 1]), inf * sin(ang[i + 1])};
      Point o = (Point){0, 0};
      bool ok1, ok2, ok3, ok4;
      Point a1 = segcross(o, c1, s1.a, s1.b, ok1);
      Point a2 = segcross(o, c1, s2.a, s2.b, ok2);
      Point a3 = segcross(o, c2, s2.a, s2.b, ok3);
      Point a4 = segcross(o, c2, s1.a, s1.b, ok4);
      ans += area(a1, a2, a3, a4);
    }
  }
  cout << ans << endl;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int m;
    cin >> m;
    Point tem;
    for (int j = 1; j <= m; ++j) {
      cin >> tem.x >> tem.y;
      pol[i].push_back(tem);
      ang[++cnt] = atan2l(tem.y, tem.x);
    }
    pol[i].push_back(pol[i][0]);
  }
  ang[++cnt] = -pi;
  ang[++cnt] = pi;
  sort(ang + 1, ang + 1 + cnt);
  cnt = unique(ang + 1, ang + 1 + cnt) - ang - 1;
  for (int i = 1; i <= n; ++i) {
    for (int k = 0; k < pol[i].size() - 1; ++k) {
      add_seg(pol[i][k], pol[i][k + 1]);
    }
  }
  solve();
  return 0;
}