#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <complex>
#include <iostream>
#include <vector>
#include <utility>
#define EPS (1e-10)
#define X real()
#define Y imag()
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;

double dot(P a, P b){
  return a.X*b.X + a.Y*b.Y;
}

double cross(P a, P b){
  return a.X*b.Y - a.Y*b.X;
}

P intersection(L a, L b){
  //??´???a??¨??´???b?????????
  //assert(abs(-cross(b.second-b.first,a.second-b.first)+cross(b.second-b.first,a.first-b.first)) > EPS);
  //P ret = a.first + abs(cross(b.second-b.first,a.first-b.first))/(-cross(b.second-b.first,a.second-b.first)+cross(b.second-b.first,a.first-b.first))*(a.second-a.first);
  //cout << a.first << " " << a.second  << " " << b.first << " " << b.second << " ret = " << ret << endl;
  return a.first + cross(b.second-b.first,a.first-b.first)/(-cross(b.second-b.first,a.second-b.first)+cross(b.second-b.first,a.first-b.first))*(a.second-a.first);
}

  
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if( cross(b,c) > EPS ) return +1;
  if( cross(b,c) < -EPS ) return -1;
  if( dot(b,c) < 0 ) return +2;
  if( abs(b-a) + EPS < abs(c-a) ) return -2;
  return 0;
}

bool is_cross(L a, L b){
  if(ccw(a.first,a.second,b.first)*ccw(a.first,a.second,b.second) <= 0 &&
     ccw(b.first,b.second,a.first)*ccw(b.first,b.second,a.second) <= 0) return true;
  return false;
}

int main(){
  double W, H;
  int N;
  while(cin >> W >> H >> N, W){
    vector<L> V;
    double x, y;
    vector<double> S;
    S.push_back(0);

    for(int i = 0; i < 2*N; ++i){
      cin >> x >> y;
      L tmp;
      if(abs(x) > EPS && abs(W-x) > EPS){
	//V.push_back(L(P(0, W*y/x), P(W*y/(W-x), 0)));
	tmp = L(P(0, W*y/x), P(W*y/(W-x), 0));
	S.push_back(W*y/(W-x));
      }else if(abs(x) > EPS){
	//V.push_back(L(P(0, y), P(H, y)));
	tmp = L(P(0, y), P(H, y));
	S.push_back(H);
      }else{
	//V.push_back(L(P(y, 0), P(y, H)));
	tmp = L(P(y, 0), P(y, H));
	S.push_back(y);
      }
      V.push_back(tmp);

      if((abs(cross(tmp.first-tmp.second, P(H,0))) > EPS) && is_cross(tmp,L(P(0,H),P(H,H)))){
	S.push_back(intersection(tmp,L(P(0,H),P(H,H))).X);
      }

    }
    
    /*
    for(int i = 0; i < 2*N; ++i)
      cout << V[i].first << " " << V[i].second << endl;
    */

    for(int i = 0; i < 2*N; ++i){
      for(int j = 0; j < i; ++j){
	if((abs(cross(V[j].first-V[j].second, V[i].first-V[i].second)) > EPS) && is_cross(V[i],V[j]))
	  S.push_back(intersection(V[i],V[j]).X);
      }
    }
    S.push_back(H);

    sort(S.begin(), S.end());
    int k = (int)S.size();
    double ans = 0;

    for(int i = 1; i < k; ++i){
      double s_r = S[i], s_l = S[i-1];
      L l_r = L(P(s_r,0),P(s_r,H)), l_l = L(P(s_l,0),P(s_l,H));
      vector<double> T_l, T_r;
      if(s_r > H + EPS) break;
      for(int j = 0; j < 2*N; ++j){

	//??°??¢????????´
	if((abs(cross(V[j].first-V[j].second, P(0,H))) > EPS) && is_cross(V[j],l_r)){
	  T_r.push_back(min(intersection(V[j],l_r).Y, H) );
	}else if(V[j].second.X < s_r && V[j].first.X < s_r){
	  T_r.push_back(0);
	}else if(abs(V[j].first.X - s_r) < EPS && abs(V[j].second.X - s_r) < EPS){
	  T_r.push_back(H);
	}else{
	  T_r.push_back(H);
	}

	//??°??¢????????´
	if((abs(cross(V[j].first-V[j].second, P(0,H))) > EPS) && is_cross(V[j],l_l)){
	  T_l.push_back(min(intersection(V[j],l_l).Y, H));
	}else if(V[j].second.X < s_l && V[j].first.X < s_l){
	  T_l.push_back(0);
	}else if(abs(V[j].first.X - s_l) < EPS && abs(V[j].second.X - s_l) < EPS){
	  T_l.push_back(0);
	}else{
	  T_l.push_back(H);
	}

      }

      sort(T_l.begin(), T_l.end());
      sort(T_r.begin(), T_r.end());

      /*
      cout << "_____T_l______ s_l = " << s_l <<  endl;
      for(int i = 0; i < 2*N; ++i) cout << T_l[i] << " ";
      cout << endl;
      cout << "_____T_r______ s_r = " << s_r << endl;
      for(int i = 0; i < 2*N; ++i) cout << T_r[i] << " ";
      cout << endl;
      */
      //printf("DEBUG %.11f\n", ans/H/H);
      
      ans += (T_l[N]-T_l[N-1]+T_r[N]-T_r[N-1])*(s_r-s_l)/2.0;
      
    }
    printf("%.11f\n", ans/H/H);
  }
  return 0;
}

Measured memory_bytes: 3456