#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef double Double;
const int INF = 1<<29;
const Double PI = acos(-1);
const Double EPS = 1e-10;
typedef complex<Double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    // if (abs(a-b)<EPS) return 0;
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
Double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
Double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
  L() {}
};
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
         abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}
bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
         cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
P crosspoint(const L &l, const L &m) {
  Double A = cross(l[1] - l[0], m[1] - m[0]);
  Double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}

P o;
bool cmpAng(const P &a, const P &b) { // a<b
  //cout << a << " " << b << " " << o << endl;
  // if (abs(a-b) < EPS) return 0;
  // if (abs(a-o) < EPS) return 1;
  // if (abs(b-o) < EPS) return 0;
  // if (abs(cross(b-o,a-o)) > EPS) return cross(b-o,a-o) < 0;
  // return abs(a) < abs(b);
  if (b.imag() > o.imag() && a.imag() < o.imag()) return 1;
  else if (b.imag() < o.imag() && a.imag() > o.imag()) return 0;
  return cross(b-o,a-o) < 0;
}

bool isint(Double x) {
  return abs(round(x)-x) < EPS;
}
typedef pair<Double, int> pdi;
P p[202];
int w,h,n;
int mp[1005];
P tp[202];
Double f(Double x, bool f) {
  REP(i,n) tp[i]=p[i];
  int num = n;
  if (isint(x) && mp[int(x+EPS)] != -1) {
    //cout << "swap " << mp[int(x+EPS)] << " " << n-1 << endl;
    swap(tp[mp[int(x+EPS)]], tp[n-1]);
    num--;
  }
  o = P(0,x);
  sort(tp,tp+num,cmpAng);
  // REP(i,num) cout << tp[i] << " ";cout << endl;
  Double a[2];                  // a[0]=min, a[1]=max

  L right(P(w,0),P(w,h));
  REP(i,2) {
    P q;
    if (num != n) {        // xに苺がある
      if (f) {             // 苺の上
        if (!i && num==1) {
          a[0] = 0;
          continue;
        }
        q = (i?tp[n/2-1]:tp[n/2-2]);
      } else {                  // 苺の下
        if (i && num==1) {
          a[1] = h;
          continue;
        }
        q = (i?tp[n/2]:tp[n/2-1]);
      }
    } else {
      q = (i?tp[n/2]:tp[n/2-1]);
    }
    L l(P(0,x),q);
    if (intersectLS(l,right)) {
      P cp = crosspoint(l,right);
      a[i] = min((Double)h,max((Double)0,cp.imag()));
    } else {
      if (q.imag() > x) {
        a[i] = h;
      } else {
        a[i] = 0;
      }
    }
  }
  // cout << a[0] << "," << a[1] << endl;
  return max((Double)0,(a[1]-a[0]))/h;
}

int main() {
  while(cin>>w>>h>>n,w||h||n) {
    n*=2;
    REP(i,n) cin >> p[i].real() >> p[i].imag();
    p[n] = P(w,0);
    p[n+1] = P(w,h);
    vector<Double> v;
    L left(P(0,0),P(0,h));
    memset(mp,-1,sizeof(mp));
    REP(i,n+2) {
      if(i<n && p[i].real() == 0) mp[int(p[i].imag()+EPS)] = i;
      REP(j,i) {
        if (intersectLS(L(p[i],p[j]),left)) {
          //cout << p[i] << " " << p[j] << endl;
          P cp = crosspoint(L(p[i],p[j]),left);
          v.push_back(cp.imag());
        }
      }
    }
    v.push_back(0);v.push_back(h);
    sort(ALL(v));
    v.erase(unique(ALL(v)), v.end());
    Double ans = 0;
    // cout << v.size() << " " << n << endl;
    Double pre = f(v[0],1);
    bool preflag = 0;
    for (int i=0; i<v.size()-1; ++i) {
      Double a = v[i];
      Double b = v[i+1];
      Double aa, bb;

      if (isint(v[i]) && mp[int(v[i]+EPS)] != -1) {
        aa = f(a,1);
      } else {
        aa = pre;
      }
      // aa = f(a,1);
      bb = f(b,0);
      // cout << a << " " << f(a,1) << endl;
      // cout << b << " " << f(b,0) << endl;
      ans += (b-a) * (aa + bb) / 2 / h;
      pre = bb;
    }
    printf("%.11f\n",ans);
  }
}

Measured memory_bytes: 1228