Problem: Background

The kindergarten attached to the University of Aizu is a kindergarten where children who love programming gather. Yu, one of the kindergarten children, loves darts as much as programming. Yu-kun was addicted to darts recently, but he got tired of ordinary darts, so he decided to make his own darts board.

See darts for darts.

Problem

The contents of the darts that Yu-kun thought about are as follows.

The infinitely wide darts board has several polygons with scores. The player has only one darts arrow. The player throws an arrow and stabs the arrow into one of the polygons to get the score written there. If you stab it in any other way, you will not get any points.

Yu-kun decided where to throw the arrow, but it doesn't always stick exactly. The darts board is a two-dimensional plane, and the position Yu-kun is aiming for is a point (cx, cy). The place where the arrow thrown by Yu-kun sticks is selected with a uniform probability from any point included in the circle with radius r centered on the point (cx, cy). The coordinates of the exposed points do not have to be integers.

Since the information on the darts board, the position (cx, cy) that Yu-kun aims at, and the radius r are given, answer the expected value of the score that Yu-kun can get.

Constraints

The input satisfies the following conditions.

* All inputs are given as integers
* 1 ≤ n ≤ 50
* 0 ≤ cx, cy, x, y ≤ 1000
* 1 ≤ r ≤ 100
* 3 ≤ p ≤ 10
* 1 ≤ score ≤ 100
* Polygon vertices are given in such an order that they visit adjacent vertices clockwise or counterclockwise.
* The sides of a polygon do not have anything in common with the sides of another polygon
* A polygon does not contain another polygon
* If the arrow sticks on the side of the polygon, no score will be given.

Input


n cx cy r
Information on the 0th polygon
Information on the first polygon
...
Information on the (n-1) th polygon


n is the number of polygons on the darts board. Polygonal information is given in the following format.


p score
x0 y0
x1 y1
...
x (p-1) y (p-1)


p represents the number of vertices of the polygon, and score represents the score written on the polygon. Each line segment of the polygon is a line segment connecting the vertices of (xi, yi) and (xi + 1, yi + 1) (i <p-1), and (xp-1, yp-1) and (x0, It is a line segment connecting the vertices of y0).

Output

Output the expected value of the score that Yu-kun can get in one line. Any number of digits after the decimal point may be output. However, the error in the answer must not exceed 0.000001 (10-6).

Examples

Input

1 2 2 1
4 1
0 0
2 0
2 2
0 2


Output

0.2500000000


Input

1 2 2 1
4 1
0 0
5 0
5 5
0 5


Output

1.0000000000


Input

4 3 3 2
3 1
1 1
3 3
1 5
4 2
2 0
5 0
4 2
3 2
3 3
4 3
6 1
6 5
4 4
3 4
4 4
5 6
2 6


Output

1.0574955319


Input

1 10 10 1
4 10
0 0
1 0
1 1
0 1


Output

0.0000000000

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef vector< P > vecp;

struct S{
  P p,q;
  S(P p,P q) : p(p),q(q) {}  
};

struct C{
  P p;  double r;
  C(P p,double r):p(p),r(r){}
};

double eps=1e-8,  PI=acos(-1),  PI2=PI*2.0;

bool eq(double a,double b){return (b-a<eps&&a-b<eps);}
bool eq(P a,P b){return (abs(a-b)<eps);}
double Sqrt(double x){  return ( x<0 ? 0.0 : sqrt(x) ); }
double dot(P a,P b){return real(b*conj(a));}
double cross(P a,P b){return imag(b*conj(a));}

double dist(P a,P b,P c){
  if(dot(b-a,c-a)<0)return abs(c-a);
  if(dot(a-b,c-b)<0)return abs(c-b);
  return abs(cross(b-a,c-a))/abs(b-a);
}

P project(P a,P b,P c){  b-=a; c-=a; return a+b*real(c/b); }

double getTime(P a,P b){
  assert( eq(cross(a,b),0) );
  return ( dot(a,b) < 0 ? -1.0 : 1.0 ) * abs(b);
}

double getArg(P a,P b){  return arg(b*conj(a)); }

vecp getCrossPoint(C a,S b, bool debug=false){
  vecp res;
  P base=b.q-b.p,  target=project(b.p,b.q,a.p);
  double length=abs(base), h=abs(a.p-target);
  base/=length;  
  if(a.r+eps<h)return res;
  double w=Sqrt(a.r*a.r-h*h);
  double L=getTime(b.q-b.p,target-b.p)-w,  R=L+w*2.0;
  if( -eps<L && L< length+eps )res.push_back(b.p+base*L);
  if( -eps<R && R< length+eps )res.push_back(b.p+base*R);
  return res;
}


double getArea(C c,P a,P b){
  P va=c.p-a,  vb=c.p-b;
  double A=abs(va), B=abs(vb);
  double f=cross(va,vb), d=dist(a,b,c.p), res=0;
  if( eq(0, f ) )return 0;
  if(A<c.r+eps&&B<c.r+eps)return f*0.5;
  if(d>c.r-eps)return c.r*c.r*PI*getArg(va,vb)/PI2;
  
  vecp u=getCrossPoint(c, S(a,b) );
  assert( !u.empty() );
  u.insert(u.begin(), a),  u.push_back(b);

  for(int i=0;i+1<(int)u.size();i++) res+=getArea(c,u[i],u[i+1]);
  return res;
}

double getArea(vecp t,C c){
  int n=t.size();
  if(n<3)return 0;
  double res=0;
  for(int i=0;i<n;i++){
    P a=t[i], b=t[(i+1)%n];
    res+=getArea(c,a,b);
  }
  return res;
}


void change(vecp t){
  int n=t.size();
  double sum=0;
  for(int i=0;i<n;i++){
    P a=t[i];
    P b=t[(i+1)%n];
    sum+= cross(a,b)*0.5;
  }
  if(sum<0){
    reverse(t.begin(),t.end());
  }
}

int main(){
  int n,cx,cy,cr;
  cin>>n>>cx>>cy>>cr;
  C cir( P(cx,cy) ,cr);
  double ans=0;
  for(int i=0;i<n;i++){
    int k,score;
    cin>>k>>score;
    vecp G;
    for(int j=0;j<k;j++){
      int x,y;
      cin>>x>>y;
      G.push_back(P(x,y));
    }
    change(G);
    ans+= getArea(G,cir)*score;
  }
  ans/= cir.r*cir.r*PI;
  printf("%.10f\n",ans);
  return 0;
}