#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 210

typedef double P_type;
typedef complex<P_type> P;
const P_type P_eps = 1e-8; //整数の時はゼロ

namespace std{
  template<class T> bool operator<(const complex<T> &a, const complex<T> &b){
    return a.real() == b.real() ? a.imag() < b.imag() : a.real() < b.real();
  }
};

P rotate(P p, double theta){
  return p * P(cos(theta), sin(theta));
}

//内積
double dot(P a, P b) {
  return (a * conj(b)).real();
}

//外積
double cross(P a, P b) {
  return (conj(a) * b).imag();
}

//反時計回り
int ccw(P a, P b, P c){
  if(cross(b-a,c-a) > P_eps) return 1; //COUNTER_CLOCKWISE
  if(cross(b-a,c-a) < -P_eps) return -1; //CLOCKWISE
  if(dot(b-a,c-a) < -P_eps) return -2; //c -> a -> b
  if(dot(a-b,c-b) < -P_eps) return 2; //a -> b -> c
  return 0; //a -> c -> b
}

/* 直線交差判定 */
bool isIntersectedLL(P a1, P a2, P b1, P b2){
  return abs(cross(a1-a2, b1-b2)) > P_eps;
}

/* 直線/線分交点 */
P getCrosspointLL(P a1, P a2, P b1, P b2) {
  //assert(isIntersectedLL(a1, a2, b1, b2));
  P a = a2 - a1;
  P b = b2 - b1;
  return a1 + a * cross(b, b1-a1) / cross(b, a);
}


int w, n, h;

bool solve(){
  P p[SIZE+2];
  
  scanf("%d%d%d", &w, &h, &n);

  if (w == 0) return false;
  
  for(int i=0;i<n*2;i++){
    int x, y;
    scanf("%d%d", &x, &y);

    p[i] = P(x,y);
  }

  p[2*n+0] = P(w,0);
  p[2*n+1] = P(w,h);
  p[2*n+2] = P(0,0);
  p[2*n+3] = P(0,h);

  double ans = 0;

  vector<double> vec;
  
  for(int i=0;i<n*2+4;i++){
    for(int j=0;j<n*2+4;j++){
      if(p[i].real() >= p[j].real()) continue;

      int counter1 = 0, counter2 = 0;
      
      for(int k=0;k<2*n;k++){
        if(ccw(p[i], p[j], p[k]) != 1) counter1++;
        if(ccw(p[i], p[j], p[k]) != -1) counter2++;
      }

      if(counter1 == n)
        vec.push_back(getCrosspointLL(p[i], p[j], P(0,0), P(0,h)).imag());

      if(counter2 == n)
        vec.push_back(getCrosspointLL(p[i], p[j], P(0,0), P(0,h)).imag());

      if(counter2 >= n && counter1 >= n)
        vec.push_back(getCrosspointLL(p[i], p[j], P(0,0), P(0,h)).imag());
        
    }
  }
  vec.push_back(0);
  vec.push_back(h);
  
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());

  for(int i=0;i<vec.size();i++){
    //debug(vec[i]);
  }
  
  int m = vec.size();
  
  for(int i=0;i<m-1;i++){
    if(vec[i] < 0) continue;
    if(vec[i] > h) continue;
    
    P a = P(0, (min((double)h, vec[i+1]) + vec[i]) / 2);
    P c1 = P(INF,INF), c2 = P(-1,-1); 
    for(int j=0;j<n*2+2;j++){
      if (p[j].real() == 0) continue;
      
      P b = p[j];
      int counter1  = 0, counter2 = 0;

      for(int k=0;k<2*n;k++){
        if(ccw(a, b, p[k]) != 1) counter1++;
        if(ccw(a, b, p[k]) != -1) counter2++;
      }
      
      if(counter1 == n && c1.imag() > p[j].imag()) c1 = p[j];
      if(counter2 == n && c2.imag() < p[j].imag()) c2 = p[j];
    }

    //debug(a);
    //debug(c1); debug(c2);

    if(c1 != P(INF,INF) && c2 != P(-1,-1)){
      if (!isIntersectedLL(a, c1, P(w,0), P(w,h)) || !isIntersectedLL(a, c2, P(w,0), P(w,h))) continue;
      double r1 = getCrosspointLL(a, c1, P(w,0), P(w,h)).imag();
      double r2 = getCrosspointLL(a, c2, P(w,0), P(w,h)).imag();

      //debug(r1); debug(a); debug(c1);
      //debug(r2); debug(a); debug(c2);

      r1 = min((double)h,max(r1, 0.0));
      r2 = min((double)h,max(r2, 0.0));
      
      if(r1 < r2){
        double calc = (r2 - r1) / h * (min((double)h, vec[i+1]) - vec[i]) / h;
        ans += (r2 - r1) / h * (min((double)h, vec[i+1]) - vec[i]) / h;
      }
    }
  }
  
  printf("%.10lf\n", ans);

  return true;
}

int main(){
  while(solve());
  
  return 0;
}



Measured memory_bytes: 3220