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;
struct Point {
  long double x, y;
  inline long double ygol() const { return atan2l(y, x); }
  inline long double sqd() const { return x * x + y * y; }
};
struct Line {
  long double a, b, c;
  Line() {}
  Line(Point p1, Point p2)
      : a(p1.y - p2.y), b(p2.x - p1.x), c(-(a * p1.x + b * p1.y)) {}
};
inline Line byYgol(long double yy) {
  return Line(Point{0, 0}, Point{cosl(yy), sinl(yy)});
}
inline long double det(long double a, long double b, long double c,
                       long double d) {
  return a * d - b * c;
}
const long double eps = 1e-9;
inline bool eq(long double a, long double b) { return abs(a - b) < eps; }
inline bool leq(long double a, long double b) { return a < b || eq(a, b); }
inline bool lt(long double a, long double b) { return a < b && !eq(a, b); }
inline Point intr(Line l1, Line l2, bool &ok) {
  long double d0 = det(l1.a, l2.a, l1.b, l2.b);
  long double d1 = det(-l1.c, -l2.c, l1.b, l2.b);
  long double d2 = det(l1.a, l2.a, -l1.c, -l2.c);
  if (eq(d0, 0)) {
    ok = false;
    return {2112, 2112};
  }
  ok = true;
  return {d1 / d0, d2 / d0};
}
struct Segment {
  Point l, r;
  int who;
};
long double curYgol = -2112;
bool operator<(const Segment &a, const Segment &b) {
  Line ln = byYgol(curYgol);
  bool ok1, ok2;
  Point p1 = intr(ln, Line(a.l, a.r), ok1);
  Point p2 = intr(ln, Line(b.l, b.r), ok2);
  assert(ok1 && ok2);
  long double d1 = p1.sqd(), d2 = p2.sqd();
  return lt(d1, d2);
}
inline Point &operator-=(Point &p, Point q) {
  p.x -= q.x;
  p.y -= q.y;
  return p;
}
inline long double square(Point a, Point b, Point c) {
  return (a.x - b.x) * (a.y - c.y) - (a.x - c.x) * (a.y - b.y);
}
inline long double square4(Point a, Point b, Point c, Point d) {
  return 0.5 * abs(square(a, b, c) + square(a, c, d));
}
int main() {
  ios_base::sync_with_stdio(false);
  const long double pi = acosl(-1);
  int n;
  cin >> n;
  vector<Segment> segs;
  vector<long double> ygly{-pi, pi};
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    vector<int> x(k), y(k);
    for (int j = 0; j < k; ++j) {
      cin >> x[j] >> y[j];
    }
    for (int j = 0; j < k; ++j) {
      int nj = (j + 1) % k;
      ygly.push_back(atan2l(y[j], x[j]));
      segs.push_back({{(long double)x[j], (long double)y[j]},
                      {(long double)x[nj], (long double)y[nj]},
                      i});
    }
  }
  sort(begin(ygly), end(ygly), lt);
  ygly.erase(unique(begin(ygly), end(ygly), eq), end(ygly));
  int ys = ygly.size();
  int ss = segs.size();
  vector<vector<int> > add(ys + 1), del(ys + 1);
  for (int sid = 0; sid < ss; ++sid) {
    Segment s = segs[sid];
    long double ly = s.l.ygol(), ry = s.r.ygol();
    if (eq(ly, ry)) continue;
    if (ly > ry) {
      swap(ly, ry);
      swap(s.l, s.r);
    }
    if (lt(pi, ry - ly)) {
      swap(ly, ry);
      swap(s.l, s.r);
    }
    int lp = lower_bound(begin(ygly), end(ygly), ly, lt) - begin(ygly);
    int rp = lower_bound(begin(ygly), end(ygly), ry, lt) - begin(ygly);
    assert(lp != rp);
    if (lp < rp) {
      add[lp].push_back(sid);
      del[rp].push_back(sid);
    } else {
      if (lp != ys - 1) {
        add[lp].push_back(sid);
        del[ys - 1].push_back(sid);
      }
      if (rp != 0) {
        add[0].push_back(sid);
        del[rp].push_back(sid);
      }
    }
  }
  set<pair<Segment, int> > st;
  long double answr = 0.0;
  for (int yid = 0; yid + 1 < ys; ++yid) {
    for (int sid : del[yid]) {
      st.erase({segs[sid], sid});
    }
    curYgol = (ygly[yid] + ygly[yid + 1]) * 0.5;
    for (int sid : add[yid]) {
      st.emplace(segs[sid], sid);
    }
    if (!st.empty()) {
      assert((int)st.size() >= 2);
      Segment s1 = begin(st)->first;
      Segment s2 = next(begin(st))->first;
      assert(s1.who == s2.who);
      Line l1 = byYgol(ygly[yid]), l2 = byYgol(ygly[yid + 1]);
      bool ok1, ok2, ok3, ok4;
      Point p1 = intr(l1, Line(s1.l, s1.r), ok1);
      Point p2 = intr(l2, Line(s1.l, s1.r), ok2);
      Point p3 = intr(l2, Line(s2.l, s2.r), ok3);
      Point p4 = intr(l1, Line(s2.l, s2.r), ok4);
      assert(ok1 && ok2 && ok3 && ok4);
      answr += square4(p1, p2, p3, p4);
    }
  }
  cout << fixed << setprecision(10) << answr << endl;
  return 42 ^ 42;
}