/*
TASK:area
LANG:C++
*/
#include <iostream>
#include <cmath>
using namespace std;
struct point
{
       double x,y;
};
struct line
{
       point A,B;
};
point T;
point p[10000];
point pe[10000];
line l[10000];
int end1,end2,end3;
double CP(point p0,point p1,point p2)
{
      double dx1=p1.x-p0.x;
      double dy1=p1.y-p0.y;
      double dx2=p2.x-p0.x;
      double dy2=p2.y-p0.y;
   return dx1*dy2-dx2*dy1;
}
point getPoint(line L1,line L2)
{
      point tmp;
      if(L1.B.x-L1.A.x ==0)
      {
                             double a2=(L2.B.y-L2.A.y)/(L2.B.x-L2.A.x);
                             double b2=L2.A.y-a2*L2.A.x;                                      
                       tmp.x=L1.B.x;
                       tmp.y=a2*tmp.x+b2;
                       return tmp;
      }
      if(L2.B.x-L2.A.x ==0)
      {
      double a1=(L1.B.y-L1.A.y)/(L1.B.x-L1.A.x);
      double b1=L1.A.y-a1*L1.A.x;
      tmp.x=L2.B.x;
      tmp.y=a1*tmp.x+b1;
      return tmp;      
      }
                       
      double a1=(L1.B.y-L1.A.y)/(L1.B.x-L1.A.x);
      double b1=L1.A.y-a1*L1.A.x;
      double a2=(L2.B.y-L2.A.y)/(L2.B.x-L2.A.x);
      double b2=L2.A.y-a2*L2.A.x;   
      
      tmp.x=(b2-b1)/(a1-a2);
      tmp.y=a1*tmp.x+b1;
      
      return tmp;
}
void check()
{
     for(int i=1;i<end1;i++)
             if(CP(l[end1].A,l[end1].B,l[i].A)*CP(l[end1].A,l[end1].B,l[i].B)<=0)
                   {  p[++end2]=getPoint(l[i],l[end1]);
 //                     cout<<p[end2].x<<" "<<p[end2].y<<endl;
                   }
}
     
void insertLine(int a,int b,int c,int d)
{
//     cout<<"Line:"<<a<<" "<<b<<" "<<c<<" "<<d<<":"<<endl;
     end1++;
     l[end1].A.x=a;
     l[end1].A.y=b;
     l[end1].B.x=c;
     l[end1].B.y=d;
     check();
}
void checkVisibility()
{
     for(int i=1;i<=end2;i++)
     {
             bool dae=1;
             for(int j=1;j<=end1;j++)
                     if(CP(l[j].A,l[j].B,T)*CP(l[j].A,l[j].B,p[i])<-0.1)
                                                                     dae=0;
                     if(dae)
                           pe[++end3]=p[i];
     }
}
bool cmp(point p1,point p2)
{
     return CP(pe[1],p1,p2)>0;
}
int S()
{
//    cout<<"pts:"<<endl;
    double s=0;
    sort(pe+2,pe+end3+1,cmp);
    pe[++end3]=pe[1];
    for(int i=1;i<=end3;i++)
    {
//            cout<<pe[i].x<<" "<<pe[i].y<<endl;
            s+=CP(pe[1],pe[i],pe[i+1])/2.;
    }
    return abs(s);
}
int main()
{
//    freopen("manii.in","r",stdin);
    int a,b,c,d,n;
    cin>>a>>b>>c>>d;
    insertLine(a,b,c,b);
    insertLine(a,b,a,d);
    insertLine(a,d,c,d);
    insertLine(c,b,c,d);
    cin>>T.x>>T.y;
    cin>>n;
    for(int i=2;i<=n+1;i++)
    {
            cin>>a>>b>>c>>d;
            insertLine(a,b,c,d);
    }
    checkVisibility();
    cout<<S()<<endl;
    
//    system("PAUSE");
}
