#include <bits/stdc++.h>
using namespace std;
const long long M = 1e5 + 100;
long long r[M], l[M], n, k[M], ra[M], p;
long double ans, x[M], y[M];
int main() {
  cout << setprecision(22) << fixed;
  ios::sync_with_stdio(false);
  cin >> n >> p;
  for (long long i = (0); i <= (n - 1); i++) {
    cin >> l[i] >> r[i];
    k[i] = ((long long)(r[i] / p) - ((long long)(l[i] - 1) / p));
    ra[i] = ((r[i] - l[i] + 1));
    x[i] = (long double)(1000.0 * (k[i]) / ra[i]);
    y[i] = 1000.0 - x[i];
  }
  for (long long i = (0); i <= (n - 1); i++) {
    ans += 2 * x[i];
    ans += (long double)2.0 * (y[i]) * (x[(i + 1) % n]) * x[(i + n - 1) % n] /
           1000000.0;
    ans += (long double)1.0 * (y[i]) * (y[(i + 1) % n]) * x[(i + n - 1) % n] /
           1000000.0;
    ans += (long double)1.0 * (y[i]) * (x[(i + 1) % n]) * y[(i + n - 1) % n] /
           1000000.0;
  }
  cout << ans;
  return 0;
}
