#include<complex>
#include<vector>
#include<iostream>
#include<stack>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<set>
 
enum CCW{FRONT=0x01,RIGHT=0x02,BACK=0x04,LEFT=0x08,OVER=0x10};

#define sc second
#define fr first
 
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define foreach(i,o) for(__typeof((o).begin()) i = (o).begin(); i != (o).end(); ++i)
 
using namespace std;
 
typedef double elem;
typedef complex<elem> point, vec;
typedef pair<point, point> line, hline, seg, pp;
 
const elem infty = 1e40;
const elem eps = 1.0e-10;
const elem pi = 2.0 * acos(0.0);
point base;
 
// ®¬_Ìô¢AÈÇ
inline bool eq(elem a, elem b){ return abs(a-b) < eps; }
inline bool eqv(vec a, vec b){ return eq( abs(b-a),0); }
 
namespace std{
  bool operator<(const point &a, const point &b){
    if(!eq(a.real(),b.real()))return a.real()<b.real();
    if(!eq(a.imag(),b.imag()))return a.imag()<b.imag();
    return false;
  }
}
 
// ð_«
struct Point{
  point p;
  Point(point p):p(p){}
  Point(double x, double y):p(x,y){}
  bool operator<(const Point &t)const{
    if( !eq( p.imag(), t.p.imag() ) ) return p.imag() < t.p.imag();
    if( !eq( p.real(), t.p.real() ) ) return p.real() < t.p.real();
    return false;
  }
};

inline elem varg(vec a, vec b){
  elem ret=arg(a)-arg(b);
  /*
  if(ret<0)ret+=2*pi;
  if(ret>2*pi)ret-=2*pi;
  if(eq(ret,2*pi))ret=0;
  */
  return ret;
}
inline elem dot(vec a, vec b){ return (a.real() * b.real() + a.imag() * b.imag() ); }
inline elem cross(vec a, vec b){ return ( a.real() * b.imag() - a.imag() * b.real() ); }
 
// ñ_Ô£A¼üÆ_ÌÅZ£AüªÆ_ÌÅZ£
inline elem dist(point a, point b){ return abs(a-b); }
inline elem dist_l(line l, point x){ return abs(cross(l.sc-l.fr,x-l.fr)) / abs(l.sc-l.fr); }

// CCW oXg¾ªA¸xÉæé
inline int ccw(const point &a, point b, point x){
  b -= a;
  x -= a;
  if( eq(cross(b,x),0.0) ) return OVER;
  if( cross(b,x) > 0 ) return LEFT;
  if( cross(b,x) < 0 ) return RIGHT;
}

// üªÌð·»è
inline bool intersectedSS(const seg &a, const seg &b)
{
  int cwaf=ccw(a.fr,a.sc,b.fr);
  int cwbf=ccw(b.fr,b.sc,a.fr);
  int cwas=ccw(a.fr,a.sc,b.sc);
  int cwbs=ccw(b.fr,b.sc,a.sc);
  if( cwaf==OVER || cwas==OVER || cwbf==OVER || cwbs==OVER ) return true;
  return ( cwaf | cwas ) == (LEFT|RIGHT) && ( cwbf | cwbs ) == (LEFT|RIGHT);
}
 
// ¼üÌð·»è
inline bool intersectedLL(line a, line b){ return !eq( cross(a.sc-a.fr,b.sc-b.fr), 0.0 ); }

// ð_vZ
inline point intersectionSS(seg a, seg b)
{
  elem d1 = dist_l(b,a.fr);
  elem d2 = dist_l(b,a.sc);
  return a.fr + ( d1 / (d1 + d2 ) ) * (a.sc-a.fr);
}
inline point intersectionLL(line a, line b)
{
  vec va = a.sc - a.fr;
  vec vb = b.sc - b.fr;
  return a.fr + va * ( cross(vb, b.fr - a.fr) / cross(vb,va) );
}
 
// üªð_êÅ
inline bool intersectionLL(line a, line b, point &ret){
  return intersectedLL( a, b ) ? ret = intersectionLL( a, b ), true : false;
}
inline bool intersectionLS(line l, seg s, point &ret){
  point tmp;
  return intersectionLL(l,s,tmp) ? ( ccw(s.fr,s.sc,tmp)&OVER ? ret=tmp, true : false ) : false;
}

/*
elem getHeight(elem W, elem H, const point &p, const vector<point> &vp){
  elem minh = 2*H;
  elem maxh = -2*H;
  bool modified = false;
  for(int i = 0; i < (int)vp.size()+2; ++i){
    int left = 0;
    int right = 0;
    int over = 0;
    point is;
    point pp;
    seg s(point(W,0),point(W,H));

    if( i == (int)vp.size() ){
      pp = point(W,0);
    }else if( i == (int)vp.size() + 1 ){
      pp = point(W,H);
    }else pp = vp[i];

    if( intersectionLS(line(p,pp),s,is) ){
      for(int j = 0; j < (int)vp.size(); ++j){
        int cw = ccw(p,pp,vp[j]);
        if( cw == LEFT ) ++left;
        else if( cw == RIGHT ) ++right;
        else ++over;
      }
      if( abs(left - right) == over && is.imag() >= -eps && is.imag() <= H+eps ){
        //cout << "  imag = " << is.imag() << " lro = " << left << ' ' << right << ' ' << over << " size = " << vp.size() << endl;
        minh = min(minh, is.imag());
        maxh = max(maxh, is.imag());
        modified=true;
      }
    }
  }
  if( !modified ) return 0;
  return abs(minh-maxh);
}
*/

inline bool divide(line l, const vector<point> &vp){
  int left = 0, right = 0, over = 0;
  for(int i = 0; i < (int)vp.size(); ++i){
    int cw = ccw(l.fr,l.sc,vp[i]);
    if( cw == LEFT ) ++left;
    else if( cw == RIGHT ) ++right;
    else ++over;
  }
  return abs(left-right)==over;
}

inline bool cmpArg(const point &a, const point &b){
  return ccw(base,a,b)==RIGHT;// < varg(vec(0,1),b-base);
};

elem getHeight(elem W, elem H, const point &p, const vector<point> &V){
  elem minH = H;
  elem maxH = 0;
  bool modi=false;
  vector<point> vp = V;

  base = point(p.real()-0.001,p.imag());
  vp.push_back(point(W,0));
  vp.push_back(point(W,H));

  //cout << vp.size() << endl;
  sort( vp.begin(), vp.end(), cmpArg );
  
  int mid = vp.size()/2;
  int imin = vp.size()<8?0:mid-4;
  int imax = vp.size()<8?vp.size()-1:mid+3;

  for(int i = imin; i <= imax; ++i){
    if( divide(line(p,vp[i]),V) ){
      point is;
      if( intersectionLL( line(p,vp[i]), seg(point(W,0),point(W,H)), is) ){
        minH = min( minH, max( 0., is.imag() ) );
        maxH = max( maxH, min( H , is.imag() ) );
      }
      modi=true;
    }
  }
  return modi?abs(minH-maxH):0;
}


int main()
{
  while(true){
    elem W,H;
    int N;
    cin >> W >> H >> N;
    if( W == 0 && H == 0 && N == 0 ) break;
    seg s(point(0,0),point(0,H));
    vector<point> vp;
    set<Point> S;
    for(int i = 0; i < 2*N; ++i){
      elem x,y;
      cin >> x >> y;
      vp.push_back( point(x,y) );
    }
    for(int i = 0; i < (int)vp.size(); ++i){
      for(int j = i+1; j < (int)vp.size()+2; ++j){
        line t;
        point is;
        bool inv = false;
        if( j == (int)vp.size() ){
          t = line(vp[i], point(W,0) );
        }else if( j == (int)vp.size()+1 ) {
          t = line(vp[i], point(W,H) );
        }else{
          t = line(vp[i],vp[j]);
          if( ccw( s.fr, s.sc, vp[i] ) == OVER &&
              ccw( s.fr, s.sc, vp[j] ) == OVER ){
            inv = true;
          }
        }
        if( inv ) continue;
        if(intersectionLS(t,s,is) && is.imag()>0 && is.imag()<H){
          S.insert( Point(is) );
        }
      }
    }
    S.insert( Point(0,0) );
    S.insert( Point(0,H) );

    elem res = 0;
    point pre = S.begin()->p;
    elem prey = pre.imag();

    //cout << S.size() << endl;

    for(set<Point>::iterator it = S.begin(); it != S.end(); ++it){
      if(it==S.begin())++it;
      
      elem y = it->p.imag();
      elem h = getHeight( W, H, (it->p+pre)/2., vp );

      //cout << pre << ' ' << it->p << ' ' << h << endl;
      res += abs(prey-y)*h;

      pre = it->p;
      prey = y;
    }
    //cout << "ysum = " << fixed << setprecision(12) << ysum << ' ' << " H = " << H << " res = " << res << endl;
    cout << fixed << setprecision(12) << res/(H*H) << endl;
  }
  return 0;
}

Measured memory_bytes: 1428