Problem: Magic Circle

Problem Statement

~ How to draw a magic circle ~

1. Prepare a sufficiently large and white floor.
2. Draw a circle with radii 1, 2, ..., R centered on the point at the floor coordinates (0,0).
3. Paint blue between the circle with radius 1 and the circle with radius 2, between the circle with radius 3 and the circle with radius 4, ... Do not paint outside the circle with radius R.
4. Draw a polygon with N vertices on the floor.
5. Repaint the white area inside the polygon with blue and the blue area with white.



It is said that the power of the magic circle becomes stronger as the magic circle contains more blue.
Therefore, I would like you to find the area of ​​the blue area included in the magic circle.

The following figure is an example of a magic circle that can be drawn by this procedure.

<image>

Constraints

* 3 ≤ N ≤ 100
* 1 ≤ R ≤ 100
* Polygons are included inside or on the circumference of a circle with radius R.
* Polygons do not have self-intersections.
* The vertices of the polygon are given in a counterclockwise order.

Input

Input follows the following format. All given numbers are integers.


N R
x_1 y_1
...
x_N y_N

(x_i, y_i) is the i-th vertex of the polygon.

Output

Output the area of ​​the blue area on one line.
The output value must have an absolute or relative error of less than 10 ^ {-8} with the true value.

Examples

Input

3 1
0 0
1 0
0 1


Output

0.500000000


Input

3 2
0 0
2 0
0 2


Output

8.995574288


Input

3 2
1 -1
1 1
-2 0


Output

11.123246567


Input

4 3
1 1
-1 1
-1 -1
1 -1


Output

11.707963268

Solution (in CPP):

Solution:
#include <cmath>
#include <iostream>
#include <complex>
#include <utility>
#include <vector>
using namespace std;
using P = complex<double>;
using L = pair<P,P>;
using C = pair<P,double>;
using Poly = vector<P>;
#define X real()
#define Y imag()
const double EPS = 1e-7, pi = acos(-1.0);

double dot(P a, P b){ return a.X*b.X + a.Y*b.Y; }
double cross(P a, P b){ return a.X*b.Y - a.Y*b.X; }
P projection(P a, P b) {return dot(a,b)/norm(b)*b;}

int ccw(P a, P b, P c){
  b -= a, c -= a;
  if(cross(b,c) > EPS) return +1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < 0) return +2;
  if(norm(b) + EPS < norm(c)) return -2;
  return 0;
}

double ps_dist(P a, L s){
  P sf = s.first, ss = s.second;
  if(dot(ss-sf,a-sf) >= 0 and dot(sf-ss,a-ss) >= 0)
    return abs(cross(sf-ss,a-ss))/abs(sf-ss);
  return min(abs(a-sf),abs(a-ss));
}

double pl_dist(P a, L s){
  P sf = s.first, ss = s.second;
  return abs(cross(sf-ss,a-ss))/abs(sf-ss);
}

vector<P> cpcl(C c, L l){
  double d = pl_dist(c.first,l), r = c.second;
  P lf = l.first, ls = l.second;
  P m = lf + projection(c.first-lf,ls-lf);
  P x = sqrt(r*r-d*d)/abs(ls-lf)*(ls-lf);
  vector<P> cp(2,m);
  cp[0] -= x;
  cp[1] += x;
  return cp;
}

double common_area_cp(C c, Poly p){
  double ret = 0, r = c.second;
  int n = p.size();
  for(int i = 0; i < n; ++i) p[i] -= c.first;
  for(int i = 0; i < n; ++i){
    P cur = p[i], nex = p[(i+1)%n];
    if(abs(cur*nex) < EPS) continue;
    double d = arg(nex/cur);
    ret += r*r*d/2.;
    if(ps_dist(P(0,0),L(cur,nex)) < r -EPS){
      vector<P> cps = cpcl(C(P(0,0),r),L(cur,nex));
      P a, b;
      if(ccw(cur,nex,cps[0]) == 0 and
         ccw(cur,nex,cps[1]) == 0)
        a = cps[0], b = cps[1];
      else if(!ccw(cur,nex,cps[0]))
        a = cps[0], b = nex;
      else if(!ccw(cur,nex,cps[1]))
        a = cur, b = cps[1];
      else
        a = cur, b = nex;
      if(abs(a*b) < EPS) continue;
      d = arg(b/a);
      ret += cross(a,b)*0.5 - r*r*d*0.5;
    }
  }
  return ret;
}

int main(){
  int N;
  double R;
  cin >> N >> R;
  vector<P> pol;
  for(int i = 0; i < N; ++i){
    double x, y;
    cin >> x >> y;
    pol.emplace_back(x,y);
  }
  double ans = 0;
  for(int i = 0; i < R; ++i){
    C c(P(0,0),i+1);
    double a = (i+1)*(i+1)*pi;
    if(not i){
      ans += common_area_cp(c,pol);
      //cerr << common_area_cp(c,pol) << endl;
      continue;
    }
    double t = common_area_cp(c,pol) - common_area_cp(C(P(0,0),i),pol);
    if(i%2) ans += a - i*i*pi - t;
    else ans += t;
  }
  printf("%.12f\n",ans);
}