#include <bits/stdc++.h>
using namespace std;
int main() {
  cout << setprecision(9) << fixed;
  int n, p;
  cin >> n >> p;
  vector<pair<long long, long long> > v;
  for (int i = 0; i < n; i++) {
    long long l, r;
    cin >> l >> r;
    v.push_back({l, r});
  }
  long double ans = 0.0000000;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      long long x = (v[0].second / p) - (v[0].first - 1) / p;
      long long y = (v[n - 1].second / p) - (v[n - 1].first - 1) / p;
      long long z = (v[1].second / p) - (v[1].first - 1) / p;
      long long hano1 = x * (v[n - 1].second - v[n - 1].first + 1) +
                        y * (v[0].second - v[0].first + 1) - x * y;
      long long hano2 = x * (v[1].second - v[1].first + 1) +
                        z * (v[0].second - v[0].first + 1) - x * z;
      long long all1 = (v[0].second - v[0].first + 1) *
                       (v[n - 1].second - v[n - 1].first + 1);
      long long all2 =
          (v[0].second - v[0].first + 1) * (v[1].second - v[1].first + 1);
      long double s = double(hano1) / double(all1) * 1000.0000000,
                  ss = (double(hano2) / double(all2)) * 1000.0000000;
      ans += s + ss;
      continue;
    }
    long long x = (v[i].second / p) - (v[i].first - 1) / p;
    long long y = (v[i - 1].second / p) - (v[i - 1].first - 1) / p;
    long long z = (v[(i + 1) % n].second / p) - (v[(i + 1) % n].first - 1) / p;
    long long hano1 = x * (v[i - 1].second - v[i - 1].first + 1) +
                      y * (v[i].second - v[i].first + 1) - x * y;
    long long hano2 = x * (v[(i + 1) % n].second - v[(i + 1) % n].first + 1) +
                      z * (v[i].second - v[i].first + 1) - x * z;
    long long all1 =
        (v[i].second - v[i].first + 1) * (v[i - 1].second - v[i - 1].first + 1);
    long long all2 = (v[i].second - v[i].first + 1) *
                     (v[(i + 1) % n].second - v[(i + 1) % n].first + 1);
    long double s = double(hano1) / double(all1) * 1000.0000000,
                ss = (double(hano2) / double(all2)) * 1000.0000000;
    ans += s + ss;
  }
  cout << ans;
  return 0;
}
