#include <stdio.h>
#include <iostream>
#include <cstring>
const int maxn = 105;
using namespace std;
int a[maxn];
double dp[maxn];
double g[maxn][maxn];
double quick[maxn];
double mem[maxn][maxn];
inline double ccc(int n,int m) {
if(mem[n][m]<=1e-9) {
if(m==0) return quick[n];
if(n==m) {
return quick[n];
}
double ret = ccc(n-1,m)*1.0/2.0+ccc(n-1,m-1)*1.0/2.0;
mem[n][m] = ret;
return ret;
}else{
return mem[n][m];
}
}
int main() {
memset(mem,0,sizeof(mem));
int n,c,k;
cin>>n>>c>>k;
for(int i = 1; i<=k; i++) {
int x,y;
cin>>x>>y;
for(int i = x; i<=y; i++) a[i]++;
}
quick[0] = 1;
quick[1] = 1.0/2.0;
for(int i = 2; i<=k; i++) {
quick[i] = quick[i-1]*1.0/2.0;
}
g[0][1] = 1;
for (int i=0; i<=k; ++i)
for (int j=0; j<c; ++j)
for (int k=0; k<c; ++k) g[i+1][j*k%c] += g[i][j]/c;
for(int i = 1; i<=k; i++) {
double z = 1;
if(a[i]) z += a[i];
}
double ans = 0;
for(int i = 1; i<=n; i++) {
for(int j = 0; j<=a[i]; j++) {
double ck = ccc(a[i],j);
for(int z = 0; z<c; z++) {
ans+=ck*g[j][z]*z;
}
}
}
printf("%.3lf",ans);
return 0;
}