#include <bits/stdc++.h>

using namespace std;

#define uniq(xs) ((xs).erase(unique((xs).begin(), (xs).end()), (xs).end()))

namespace {

    typedef double real;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }

    const real EPS = 1e-9;
    bool EQ(real x, real y) { return abs(x - y) < EPS; }

    struct Point {
        real x, y;
        Point() {}
        Point(real x, real y) : x(x), y(y) {}
        Point operator+(const Point& p) const { return Point(x + p.x, y + p.y); }
        Point operator-(const Point& p) const { return Point(x - p.x, y - p.y); }
        Point operator*(real k) const { return Point(k * x, k * y); }
        Point operator/(real k) const { return Point(x / k, y / k); }
        bool operator==(const Point p) const { return EQ(x, p.x) && EQ(y, p.y); }
    };
    inline real dot(const Point& a, const Point& b) { return a.x * b.x + a.y * b.y; }
    inline real cross(const Point& a, const Point& b) { return a.x * b.y - a.y * b.x; }
    inline real norm(const Point& a) { return sqrt(dot(a, a)); }
    Point rot90(const Point& p) { return Point(-p.y, p.x); } // 反時計回りに90度回転 
    ostream& operator<<(ostream& os, const Point& p) { return os << "(" << p.x << "," << p.y << ")"; }
    istream& operator>>(istream& is, Point& p) { return is >> p.x >> p.y; }

    struct Line {
        Point a, b;
        Line() {}
        Line(const Point& a, const Point& b) : a(a), b(b) {}
    };

    int ccw(Point a, Point b, Point c){
        b = b - a; c = c - a;
        if (cross(b, c) > EPS) return +1;      // a,b,cの順に反時計周り
        if (cross(b, c) < -EPS) return -1;     // a,b,cの順に時計周り
        if (dot(b, c) < 0) return +2;          // c--a--b 直線
        if (norm(b) < norm(c)) return -2;      // a--b--c 直線
        return 0;                              // a--c--b 直線
    }

    ostream& operator<<(ostream& os, const Line& l) {
        return os << "Line(" << l.a << "," << l.b << ")";
    }
    Point crosspoint(const Line& s, const Line& t) {
        real d = cross(t.b - t.a, s.b - s.a);
        return s.a + (s.b - s.a) * cross(t.b - t.a, t.b - s.a) / d;
    }

    int W, H, N;
    vector<Point> S;
    bool input() {
        cin >> W >> H >> N;
        if (W == 0) return false;
        S.clear(); S.resize(2 * N);
        for (int i = 0; i < 2 * N; i++) cin >> S[i];
        return true;
    }

    bool comp(const Point& a , const Point& b) {
        return a.y < b.y;
    }

    bool C(real l, real r, int d) {
        int lb = 0, ub = 2 * N;
        while (lb + 1 < ub) {
            int mid = (lb + ub) / 2;
            ((S[mid].y <= min(l, r)) ? lb : ub) = mid;
        }
        Point a(0, l);
        Point b(W, r);
        int c = 0;
        for (int i = lb; i < 2 * N; i++) {
            if (ccw(a, b, S[i]) == 1) c++;
        }
        return c >= N + d;
    }

    real calc(real y) {
        real lb = 0, ub = H;
        for (int k = 0; k < 40; k++) {
            real mid = (lb + ub) / 2;
            (C(y, mid, 0) ? lb : ub) = mid;
        }
        real x = lb;
        lb = 0, ub = H;
        for (int k = 0; k < 40; k++) {
            real mid = (lb + ub) / 2;
            (C(y, mid, 1) ? lb : ub) = mid;
        }
        return x - lb;
    }

    void solve() {
        sort(S.begin(), S.end(), comp);
        Line L(Point(0, 0), Point(0, H));
        Line R(Point(W, 0), Point(W, H));
        vector<Point> VL;
        VL.push_back(L.a); VL.push_back(L.b);
        for (int i = 0; i < 2 * N; i++) {
            if (EQ(S[i].x, W)) continue;
            Point p = crosspoint(L, Line(R.a, S[i]));
            if (ccw(L.a, L.b, p) == 0) { VL.push_back(p); }
            p = crosspoint(L, Line(R.b, S[i]));
            if (ccw(L.a, L.b, p) == 0) { VL.push_back(p); }
        }
        for (int i = 0; i < 2 * N; i++) {
            for (int j = i + 1; j < 2 * N; j++) {
                Point a = S[i], b = S[j];
                if (EQ(a.x, b.x)) continue;
                Point p = crosspoint(L, Line(a, b));
                if (ccw(L.a, L.b, p) == 0) { VL.push_back(p); }
            }
        }
        sort(VL.begin(), VL.end(), comp);
        uniq(VL);
        real ans = 0;
        for (int i = 0; i + 1 < VL.size(); i++) {
            real y0 = (VL[i].y + VL[i + 1].y) / 2;
            ans += calc(y0) * (VL[i + 1].y - VL[i].y) / (H * H);
        }
        printf("%.12f\n", ans);
    }
}

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

Measured memory_bytes: 1644