#include <bits/stdc++.h>
using namespace std;
const int MAX = 100010;
long long range[MAX];
long long cnt[MAX];
void calc(int n) {
  double sum = 0;
  for (int i = 0; i < n; i++) {
    long double r0 = (i == 0) ? range[n - 1] : range[i - 1];
    long double r1 = range[i];
    long double r2 = (i == n - 1) ? range[0] : range[i + 1];
    long double c0 = (i == 0) ? cnt[n - 1] : cnt[i - 1];
    long double c1 = cnt[i];
    long double c2 = (i == n - 1) ? cnt[0] : cnt[i + 1];
    double sum1 =
        ((double)(c0 * (r1 - c1) + r0 * c1) * 1000.0 / (double)(r0 * r1));
    double sum2 =
        ((double)(c1 * r2 + (r1 - c1) * c2) * 1000.0 / (double)(r1 * r2));
    sum += sum1 + sum2;
  }
  printf("%.8f\n", sum);
}
int main() {
  int n, p;
  int r, l;
  for (int i = 0; i < MAX; i++) {
    range[i] = 0;
    cnt[i] = 0;
  }
  scanf("%d %d", &n, &p);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &l, &r);
    long long tmp = r / p - l / p;
    if (l % p == 0) tmp++;
    range[i] = r - l + 1;
    cnt[i] = tmp;
  }
  calc(n);
}
