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;
namespace zyt {
const int N = 5e4 + 10;
const double EPS = 1e-7, PI = acos(-1);
bool equal(const double a, const double b) { return fabs(a - b) < EPS; }
struct point {
  double x, y, theta;
  point(const double _x = 0, const double _y = 0) : x(_x), y(_y) { cal(); }
  void cal() { theta = atan2(y, x) + PI; }
  bool operator!=(const point &b) const {
    return !equal(x, b.x) || !equal(y, b.y);
  }
};
double cross(const point &A, const point &B) { return A.x * B.y - B.x * A.y; }
double area(const point &A, const point &B) { return fabs(cross(A, B)) / 2; }
double sq(const double x) { return x * x; }
bool internal(const double &k, const double &a, const double &b) {
  if (a <= b)
    return a <= k && k <= b;
  else
    return k >= a || k <= b;
}
struct line {
  point A, B;
  line(const point &a = point(), const point &b = point()) : A(a), B(b) {
    if (cross(A, B) < 0) swap(A, B);
  }
  bool operator<(const line &b) const;
} L[N << 1];
point get(const line &L, const double theta) {
  double kk = tan(theta);
  if (equal(L.A.x, L.B.x))
    return point(L.A.x, kk * L.A.x);
  else {
    double k = (L.A.y - L.B.y) / (L.A.x - L.B.x), b = L.A.y - k * L.A.x;
    return point(b / (kk - k), kk * b / (kk - k));
  }
}
double dis(const point &a) { return sqrt(sq(a.x) + sq(a.y)); }
double dis(const line &L, const double theta) { return dis(get(L, theta)); }
bool line::operator<(const line &b) const {
  if (A != b.A && A != b.B && internal(A.theta, b.A.theta, b.B.theta))
    return dis(*this, A.theta) < dis(b, A.theta);
  else if (B != b.A && B != b.B && internal(B.theta, b.A.theta, b.B.theta))
    return dis(*this, B.theta) < dis(b, B.theta);
  else if (b.A != A && b.A != B && internal(b.A.theta, A.theta, B.theta))
    return dis(*this, b.A.theta) < dis(b, b.A.theta);
  else if (b.B != A && b.B != B && internal(b.B.theta, A.theta, B.theta))
    return dis(*this, b.B.theta) < dis(b, b.B.theta);
  else
    return false;
}
set<line> s;
int n, m, cnt;
double d[N];
vector<int> in[N], out[N];
int unique(double *const d, const int n) {
  int cnt = 0;
  d[cnt++] = d[0];
  for (int i = 1; i < n; i++)
    if (!equal(d[i], d[cnt - 1])) d[cnt++] = d[i];
  return cnt;
}
int find(const double x) {
  int p = lower_bound(d, d + cnt, x) - d;
  return p - (!equal(d[p], x) ? 1 : 0);
}
int work() {
  scanf("%d", &n);
  d[cnt++] = 0;
  d[cnt++] = 2 * PI - EPS;
  for (int i = 0; i < n; i++) {
    int k;
    scanf("%d", &k);
    point last, first;
    scanf("%lf%lf", &first.x, &first.y);
    first.cal();
    last = first;
    d[cnt++] = first.theta;
    while (k--) {
      point p;
      if (k) {
        scanf("%lf%lf", &p.x, &p.y);
        p.cal();
      } else
        p = first;
      if (!equal(p.theta, last.theta)) {
        d[cnt++] = p.theta;
        line tmp = line(last, p);
        if (tmp.A.theta < tmp.B.theta)
          L[m++] = tmp;
        else {
          L[m++] = line(get(tmp, 2 * PI - EPS), tmp.A);
          L[m++] = line(get(tmp, 0), tmp.B);
        }
      }
      last = p;
    }
  }
  sort(d, d + cnt);
  cnt = unique(d, cnt);
  for (int i = 0; i < m; i++) {
    int a = find(L[i].A.theta), b = find(L[i].B.theta);
    if (a > b)
      fprintf(stderr, "gg1");
    else if (a < b)
      in[a].push_back(i), out[b].push_back(i);
  }
  double ans = 0;
  for (int i = 0; i < cnt - 1; i++) {
    for (auto j : out[i]) s.erase(L[j]);
    for (auto j : in[i]) s.insert(L[j]);
    if (s.size() >= 2) {
      if (s.size() < 2) fprintf(stderr, "gg2");
      line a = *s.begin(), b = *++s.begin();
      ans += area(get(b, d[i]), get(b, d[i + 1])) -
             area(get(a, d[i]), get(a, d[i + 1]));
    }
  }
  printf("%.6f", ans);
  return 0;
}
}  // namespace zyt
int main() { return zyt::work(); }