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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long double PI = 4 * atanl(1);
const long double eps = 1e-11;
bool eq(long double x, long double y) { return fabsl(x - y) < eps; }
bool ls(long double x, long double y) { return x < y && !eq(x, y); }
bool lseq(long double x, long double y) { return x < y || eq(x, y); }
struct Point {
  long double x, y;
  Point() : x(), y() {}
  Point(long double _x, long double _y) : x(_x), y(_y) {}
  void scan() {
    double _x, _y;
    scanf("%lf%lf", &_x, &_y);
    x = _x;
    y = _y;
  }
  Point operator+(const Point &a) const { return Point(x + a.x, y + a.y); }
  Point operator-(const Point &a) const { return Point(x - a.x, y - a.y); }
  Point operator*(const long double &k) const { return Point(x * k, y * k); }
  Point operator/(const long double &k) const { return Point(x / k, y / k); }
  long double operator%(const Point &a) const { return x * a.x + y * a.y; }
  long double operator*(const Point &a) const { return x * a.y - y * a.x; }
  long double sqrLen() const { return *this % *this; }
  long double len() const { return sqrtl(sqrLen()); }
  Point ort() const { return Point(-y, x); }
  Point rot(const long double &ca, const long double &sa) const {
    return *this * ca + ort() * sa;
  }
  Point rot(const long double &ang) const { return rot(cosl(ang), sinl(ang)); }
  void eprint() { 42; }
};
bool onSegm(Point A, Point B, Point C) { return lseq((A - B) % (C - B), 0); }
bool intersectLines(Point A, Point a, Point B, Point b, Point &I) {
  if (eq(a * b, 0)) return false;
  long double y = ((A - B) * a) / (b * a);
  I = B + b * y;
  return true;
}
long double PHI;
struct Segm {
  Point P, Q;
  Segm() : P(), Q() {}
  Segm(Point _P, Point _Q) {
    P = _P;
    Q = _Q;
    if (eq(P * Q, 0)) throw;
    if (P * Q < 0) swap(P, Q);
  }
  long double getPointInDir(const long double &phi) const {
    Point I;
    Point dd = Point(1, 0).rot(phi);
    if (!intersectLines(Point(), Point(1, 0).rot(phi), P, Q - P, I)) return -1;
    return I.sqrLen();
  }
  bool operator<(const Segm &S) const {
    return ls(getPointInDir(PHI), S.getPointInDir(PHI));
  }
  void eprint() {
    P.eprint();
    Q.eprint();
    42;
  }
};
const int N = 100100;
Point a[N];
Point b[N][2];
long double c[N];
vector<Segm> ev[N][2];
int n, m;
set<Segm> setik;
void eprintSet() {
  42;
  for (Segm S : setik) S.eprint();
  42;
}
void read() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int k;
    scanf("%d", &k);
    for (int i = 0; i < k; i++) a[i].scan();
    a[k] = a[0];
    for (int i = 0; i < k; i++) {
      b[n][0] = a[i];
      b[n][1] = a[i + 1];
      n++;
    }
    for (int i = 0; i < k; i++) c[m++] = atan2l(a[i].y, a[i].x);
  }
  sort(c, c + m);
  int mm = 0;
  for (int i = 0; i < m; i++) {
    if (mm == 0 || !eq(c[i], c[mm - 1])) c[mm++] = c[i];
  }
  m = mm;
  c[m] = c[0] + 2 * PI;
  PHI = (c[m - 1] + c[m]) / 2;
  for (int i = 0; i < n; i++) {
    Point P = b[i][0], Q = b[i][1];
    if (eq(P * Q, 0)) continue;
    Segm S = Segm(P, Q);
    long double ang1 = atan2l(S.P.y, S.P.x), ang2 = atan2l(S.Q.y, S.Q.x);
    int pos1 = lower_bound(c, c + m, ang1 - eps) - c;
    int pos2 = lower_bound(c, c + m, ang2 - eps) - c;
    ev[pos1][0].push_back(S);
    ev[pos2][1].push_back(S);
    if (pos1 > pos2) setik.insert(S);
  }
}
long double getArea2(Segm S, long double phi1, long double phi2) {
  long double A = S.getPointInDir(phi1), B = S.getPointInDir(phi2);
  if (A < -0.5 || B < -0.5) throw;
  return sinl(phi2 - phi1) * sqrtl(A * B) / 2;
}
long double getArea(long double phi1, long double phi2) {
  if (setik.empty()) return 0;
  if ((int)setik.size() == 1) return 0;
  Segm S1, S2;
  auto it = setik.begin();
  S1 = *it;
  it++;
  S2 = *it;
  return getArea2(S2, phi1, phi2) - getArea2(S1, phi1, phi2);
}
int main() {
  read();
  long double ans = 0;
  for (int i = 0; i < m; i++) {
    for (Segm S : ev[i][1]) {
      setik.erase(S);
    }
    PHI = (c[i] + c[i + 1]) / 2;
    for (Segm S : ev[i][0]) {
      setik.insert(S);
    }
    ans += getArea(c[i], c[i + 1]);
  }
  printf("%.13lf\n", (double)ans);
  return 0;
}