#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
const long double epsA=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
using D=double;
struct P{
	D x,y;
	P(D _x =D(),D _y=D()):x(_x),y(_y){}
	P operator+(const P& r) const { return {x+r.x,y+r.y};}
	P operator-(const P& r) const { return {x-r.x,y-r.y};}
	P operator*(const P& r) const { return {x*r.x-y*r.y,x*r.y+y*r.x};}
	P operator*(const D& r) const { return {x*r,y*r};}
	P operator/(const D& r) const { return {x/r,y/r};}
	D norm() const {return x*x+y*y;}
	D abs() const{return sqrt(norm());}
	D rabs() const{return max(std::abs(x),std::abs(y));}
	D arg() const{return atan2(y,x);}
};
struct L{
	P s,t;
	L(P _s=P(),P _t = P()):s(_s),t(_t){}
	P vec() const { return t-s;}
	P abs() const {return vec().abs();}
};
D crs(P a,P b){return a.x*b.y-a.y*b.x;}
int sgncrs(P a,P b){
	D cr=crs(a,b);
	if(abs(cr)<=(a.rabs()+b.rabs())*eps){return 0;}
	return (cr<0)?-1:1;
}
	
int clossLL(const L&l,const L&m,P&r){
	D cr1=crs(l.vec(),m.vec()),cr2=crs(l.vec(),l.t-m.s);
	if(sgncrs(l.vec(),m.vec())==0){
		r=l.s;
		if(sgncrs(l.vec(),l.t-m.s)){return 0;}
		else{return -1;}
	}
	r=m.s+m.vec()*cr2/cr1;
	return 1;
}

bool solve(void){
	int W,H,n,i,j;cin>>W>>H>>n;
	n*=2;
	if(n==0){return false;}
	vector<L>iti(n+4);
	for(i=0;i<n;i++){
		D x,y;cin>>x>>y;
		x/=W;y/=H;
		P aa={0.0,y/(1-x)};
		P bb={y/x,0.0};
		if(x==0){
			bb={1.0,y};
		}else if(x==1){
			aa={y,1.0};
		}
		iti[i]={aa,bb};
	}
	iti[n  ]={{0.0,0.0},{0.0,1.0}};
	iti[n+1]={{0.0,1.0},{1.0,1.0}};
	iti[n+2]={{0.0,0.0},{1.0,0.0}};
	iti[n+3]={{1.0,0.0},{1.0,1.0}};
	
	vector<double>syo;//衝突のx座標
	syo.reserve((n+3)*(n+4)/2);
	syo.pub(0.0);
	syo.pub(1.0);
	for(i=0;i<n+4;i++){
		for(j=i+1;j<n+4;j++){
			P pot;
			int ret=clossLL(iti[i],iti[j],pot);
			if(ret==1&&0<pot.x&&pot.x<1&&0-epsA<=pot.y&&pot.y<=1+epsA){syo.pub(pot.x);}
		}
	}
	double ans=0;
	SO(syo);
	for(i=0;i+1<syo.size();i++){
		double yko=syo[i+1]-syo[i];
		if(yko<eps){continue;}//-1e9
		double bas=(syo[i+1]+syo[i])/2;
		vector<double>ata(n);
		L sen={{bas,0.0},{bas,1.0}};
		int tate=0;
		for(j=0;j<n;j++){
			P pot;
			int ret=clossLL(sen,iti[j],pot);
			if(ret==1){ata[j]=pot.y;}
			if(ret==0){
				if(bas<iti[j].s.x){ata[j]=big;}
				else{ata[j]=-big;}
			}
			//ret=-1 つまり直線がぴったり同じパターンは実は考えなくていい
			//なぜなら、basは衝突の中央を取っているため、ぴったり重なるならykoは0のはず
		}
		SO(ata);
		double ue=min(1.0,max(0.0,ata[n/2]));
		double st=min(1.0,max(0.0,ata[n/2-1]));
		
		ans+=yko*(ue-st);
	}
	cout<<ans<<endl;
	return true;
	
}
int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	while(solve()){}
	return 0;
}



Measured memory_bytes: 3380