/*
TASK: area
LANG: C
*/
#include <stdio.h>
#include <math.h>
#define EPS 1e-9

 typedef
  struct
   {
    double x,y;
   }point;

 point a[128];
 point b[128];
 int n,m,q;
 point p,p1,p2;

 int orient (point a,point b,point c)
  {
   double pom=a.x*(b.y-c.y)+a.y*(c.x-b.x)+b.x*c.y-b.y*c.x;
   if (pom<-EPS) return -1;
   if (pom>EPS) return 1;
   return 0;
  }

 point cross (point a1,point b1,point a2,point b2)
  {
   double A1,B1,C1,A2,B2,C2;
   point ret;
   A1=a1.y-b1.y;
   B1=b1.x-a1.x;
   C1=a1.x*b1.y-a1.y*b1.x;
//
   A2=a2.y-b2.y;
   B2=b2.x-a2.x;
   C2=a2.x*b2.y-a2.y*b2.x;
//
   ret.y=(A2*C1-A1*C2)/(A1*B2-A2*B1);
   ret.x=(B2*C1-B1*C2)/(A2*B1-A1*B2);
   return ret;
  }

 void cut (point p1,point p2,int o)
  {
   int i;
   if (n==0) return;
   m=0;
   a[n+1]=a[1];
   for (i=1;i<=n;i++)
    if (orient(a[i],p1,p2)==o)
     {
      b[++m]=a[i];
      if (orient(a[i+1],p1,p2)==-o)
        b[++m]=cross(a[i],a[i+1],p1,p2);
     }
      else
       if (orient(a[i+1],p1,p2)==o)
        b[++m]=cross(a[i],a[i+1],p1,p2);
   n=m;
   for (i=1;i<=n;i++)
    a[i]=b[i];
  }

 int main ()
  {
   int i;
   double area;
   n=4;
   for (i=1;i<=3;i+=2)
    scanf("%lf%lf",&a[i].x,&a[i].y);
   a[2].x=a[3].x;
   a[2].y=a[1].y;
   a[4].x=a[1].x;
   a[4].y=a[3].y;
   scanf("%lf%lf",&p.x,&p.y);
   for (scanf("%d",&q);q>0;q--)
    {
     scanf("%lf%lf",&p1.x,&p1.y);
     scanf("%lf%lf",&p2.x,&p2.y);
     cut(p1,p2,orient(p,p1,p2));
    }
   if (n<=2)
    {
     printf("0\n");
     return 0;
    }
   area=0;
   a[n+1]=a[1];
   for (i=1;i<=n;i++)
    area+=(a[i].x-a[i+1].x)*(a[i].y+a[i+1].y);
   printf("%d\n",(int)(floor(area/2.0)+EPS));
   return 0;
  }
