#include <bits/stdc++.h>
using namespace std;
int n;
long long p;
double pd[100001][2][2];
bool mem[100001][2][2];
long long r[100010], l[100010];
long long conta(long long a, long long b) { return (b / p) - ((a - 1) / p); }
double add;
double func(int at, int prim, int ant) {
  if (at == n) return 0;
  if (mem[at][prim][ant]) return pd[at][prim][ant];
  mem[at][prim][ant] = true;
  double ans = 0.0;
  double tot = r[at] - l[at] + 1;
  double tem = conta(l[at], r[at]) / tot;
  double ntem = 1.0 - tem;
  if (at == 0) {
    ans += ntem * func(at + 1, 0, 0);
    ans += tem * (add + func(at + 1, 1, 1));
  } else if (at != n - 1) {
    ans += ntem * func(at + 1, prim, 0);
    ans += tem * (func(at + 1, prim, 1) + add + ((ant) ? 0.0 : add));
  } else {
    ans += tem * (add + ((ant) ? 0.0 : add));
    if (prim) ans += ntem * add;
  }
  return pd[at][prim][ant] = ans;
}
int main() {
  scanf("%d %lld", &n, &p);
  add = 2000.0;
  for (int i = 0; i < n; i++) scanf("%lld %lld", &l[i], &r[i]);
  memset(mem, 0, sizeof mem);
  printf("%.10lf\n", func(0, 0, 0));
  return 0;
}
