#include <bits/stdc++.h>   using namespace std;   int const MAX_N = 1e5 + 10;   int n, p, l[MAX_N], r[MAX_N];   int get_count(int l, int r) {     int ans = 0;     if (l % p == 0) ++ans;     l -= l % p;     r -= r % p;     ans += (r - l) / p;     return ans;   }   double get_prob(int a, int b) {     long long count = 0;     count +=         1LL * get_count(l[a], r[a]) * (r[b] - l[b] + 1 - get_count(l[b], r[b]));     count +=         1LL * get_count(l[b], r[b]) * (r[a] - l[a] + 1 - get_count(l[a], r[a]));     count += 1LL * get_count(l[a], r[a]) * get_count(l[b], r[b]);     return count * 1.0 / (1LL * (r[a] - l[a] + 1) * (r[b] - l[b] + 1));   }   int main() {     ios_base::sync_with_stdio(false);     cout << fixed << setprecision(12);     cin >> n >> p;     for (int i = 0; i < n; ++i) cin >> l[i] >> r[i];     double ret = 0;     for (int i = 0; i < n; ++i) {       int j = (i + 1) % n;       ret += 2000.0 * get_prob(i, j);     }     cout << ret << endl;     return 0;   }   