#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)1e5 + 2;
const int INF = (int)1e9 + 2;
long long get_right(long long l, long long r, long long p) {
  return r / p - l / p + (l % p == 0);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  int n;
  long long p;
  cin >> n >> p;
  double a[MAXN];
  for (int i = 0; i < n; ++i) {
    long long l, r;
    cin >> l >> r;
    a[i] = (double)get_right(l, r, p) / (double)(r - l + 1);
  }
  double ans = 0.0;
  for (int i = 0; i < n; ++i) {
    if (i == n - 1) {
      ans += a[n - 1] + a[0] - (a[n - 1] * a[0]);
    } else {
      ans += a[i] + a[i + 1] - (a[i] * a[i + 1]);
    }
  }
  ans *= 2000.0;
  cout << fixed << setprecision(7) << ans;
  return 0;
}
