#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <utility>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};

namespace std{
    bool operator < (const P& a, const P& b){
        return !EQ(a.X,b.X) ? a.X<b.X : a.Y+EPS<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}

bool intersectLS(const L& l, const L& s){
    return cross(l[1]-l[0], s[0]-l[0])*
        cross(l[1]-l[0], s[1]-l[0]) < EPS;
}
bool isParallel(const P &a, const P &b){
    return abs(cross(a,b)) < EPS;
}
bool isParallel(const L &a, const L &b){
    return isParallel(a[1]-a[0], b[1]-b[0]);
}
P crosspointLL(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]);
  return m[0] + B/A *(m[1]-m[0]);
}

pair<int, int> pointcount(P a, P b, const VP &p){
    int low=0, up=0;
    for(int i=0; i<(int)p.size(); i++){
        int ret = ccw(a, b, p[i]);
        if(ret == 1) up++;
        if(ret == -1) low++;
    }
    return make_pair(low, up);
}

int main(){
    while(1){
        double w,h;
        int n;
        cin >> w >> h >> n;
        if(n==0) break;

        //イチゴの位置 +四つ角
        VP p(2*n +4);
        for(int i=0; i<2*n; i++){
            double x,y;
            cin >> 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);
        //psはイチゴのみ
        VP ps = p;
        ps.erase(ps.end()-4, ps.end());
        int m = p.size();

        //左の辺におけるチェックポイント
        VP cply;
        L right(p[2*n], p[2*n +1]);
        L left(p[2*n+2], p[2*n+3]);
        for(int i=0; i<m; i++){
            for(int j=i+1; j<m; j++){
                if(p[i] == p[j]) continue;
                L line(p[i], p[j]);
                if(!isParallel(line, left) &&
                    intersectLS(line, left) && intersectLS(line, right)){
                    cply.push_back(crosspointLL(line, left));
                }   
            }
        }
        sort(cply.begin(), cply.end());
        cply.erase(unique(cply.begin(), cply.end()), cply.end());

        
        double ans = 0;
        for(int i=0; i<(int)cply.size()-1; i++){
            VP cpry;
            P midp = (cply[i] +cply[i+1])/2.0;
            //イチゴの位置で分割したときの右の辺のあり得る値を列挙
            for(int j=0; j<m; j++){
                L line(midp, p[j]);
                if(!isParallel(line, right) && intersectLS(line, right)){
                    cpry.push_back(crosspointLL(line, right));
                }
            }
            sort(cpry.begin(), cpry.end());
            cpry.erase(unique(cpry.begin(), cpry.end()), cpry.end());

            //上で列挙した値の中で、上界下界を探索
            int lb = 0, ub = cpry.size()-1;
            while(lb < ub){
                int mid = (lb +ub)/2;
                pair<int, int> ret = pointcount(midp, cpry[mid], ps);
                if(ret.second > n){
                    lb = mid+1;
                }else{
                    ub = mid;
                }
            }
            ub = lb+1;
            pair<int, int> ret = pointcount(midp, cpry[lb], ps);
            if(ret.first > n || ret.second > n) continue;
            if(ub == (int)cpry.size()) continue;
            ret = pointcount(midp, cpry[ub], ps);
            if(ret.first > n || ret.second > n) continue;

            double diff = abs(cply[i+1] -cply[i]);
            ans += abs(cpry[ub] -cpry[lb])/h *diff/h;
        }
        cout << fixed << setprecision(10);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3396