{
TASK:area
LANG:Pascal
}
program AREA;

type
 point = record
  X,Y: real;
 end;

 line = record
  P1,P2: point;
  h,v: boolean;
  a,b: real;
 end;

 PPoint = ^TPoint;
 TPoint = record
  inf: point;
  p,n: PPoint;
 end;

var
 points: PPoint;
 T: point;
 N,i: byte;

procedure CalculateLine(var l: line);
begin
 with l do
 begin
  h:=false;
  v:=false;
  a:=0;
  b:=0;
  if P1.X=P2.X then
   v:=true
  else if P1.Y=P2.Y then
   h:=true
  else
  begin
   a:=(P1.Y-P2.Y)/(P1.X-P2.X);
   b:=(P1.Y-a*P1.X);
  end;
 end;
end;

function InputLine: line;
begin
 with InputLine do
 begin
  readln(P1.X, P1.Y, P2.X, P2.Y);
  if P1.X>P2.X then
  begin
   P1.X:=P1.X+P2.X;
   P2.X:=P1.X-P2.X;
   P1.X:=P1.X-P2.X;
   P1.Y:=P1.Y+P2.Y;
   P2.Y:=P1.Y-P2.Y;
   P1.Y:=P1.Y-P2.Y;
  end;
 end;
end;

function SameSS(l: line; P1,P2: point): boolean;
var
 P1a,P2a: boolean;
begin
 if l.h then
 begin
  P1a:=(P1.Y>l.P1.Y);
  P2a:=(P2.Y>l.P1.Y);
 end
 else if l.v then
 begin
  P1a:=(P1.X>l.P1.X);
  P2a:=(P2.X>l.P1.X);
 end
 else
 begin
  P1a:=(l.a*P1.X+l.b)<P1.Y;
  P2a:=(l.a*P2.X+l.b)<P2.Y;
 end;
 SameSS:=(P1a and P2a) or not (P1a or P2a);
end;

function MakeLine(P1,P2: point): line;
var
 l: line;
begin
 if P1.X<P2.X then
 begin
  l.P1:=P1;
  l.P2:=P2;
 end
 else
 begin
  l.P2:=P1;
  l.P1:=P2;
 end;
 CalculateLine(l);
 MakeLine:=l;
end;

function FindIntersection(l: line; P1,P2: point; var P: point): boolean;
var
 stubl: line;
begin
 stubl:=MakeLine(P1,P2);

 FindIntersection:=false;
 if (l.h and stubl.h) or (l.v and stubl.v) then
  exit;

 if l.h then
 begin
  if stubl.v then
   P.X:=P1.X
  else
   P.X:=(l.P1.Y-stubl.b)/stubl.a;
  P.Y:=l.P1.Y;
 end
 else if l.v then
 begin
  if stubl.h then
   P.Y:=P1.Y
  else
   P.Y:=stubl.a*l.P1.X+stubl.b;
  P.X:=l.P1.X;
 end
 else
 begin
  if stubl.v then
  begin
   P.X:=P1.X;
   P.Y:=l.a*P1.X+l.b;
  end
  else if stubl.h then
  begin
   P.Y:=P1.Y;
   P.X:=(P1.Y-l.b)/l.a;
  end
  else
  begin
   if l.a=stubl.a then
    exit;
   P.X:=(stubl.b-l.b)/(l.a-stubl.a);
   P.Y:=l.a*P.X+l.b;
  end;
 end;

 if stubl.v then
 begin
  if stubl.P1.Y<stubl.P2.Y then
  begin
   if P.Y<stubl.P1.Y then
    exit;
   if P.Y>stubl.P2.Y then
    exit;
  end
  else
  begin
   if P.Y>stubl.P1.Y then
    exit;
   if P.Y<stubl.P2.Y then
    exit;
  end;
 end
 else
 begin
  if P.X<stubl.P1.X then
   exit;
  if P.X>stubl.P2.X then
   exit;
 end;

 FindIntersection:=true;
end;

procedure AddAfter(var list: PPoint; p: point);
var
 t: PPoint;
begin
 new(t);
 t^.inf:=p;
 t^.p:=list;
 t^.n:=list^.n;
 list^.n^.p:=t;
 list^.n:=t;
 list:=t;
end;

procedure Remove(var list: PPoint);
var
 t: PPoint;
begin
 t:=list;
 t^.p^.n:=t^.n;
 t^.n^.p:=t^.p;
 list:=t^.n;
 dispose(t);
end;

procedure ReadRect;
var
 X1,Y1,X2,Y2: real;
 p: PPoint;
begin
 readln(X1,Y1,X2,Y2);
 new(p);
 p^.inf.X:=X1;
 p^.inf.Y:=Y1;
 new(p^.n);
 p^.n^.p:=p;
 p:=p^.n;
 p^.inf.X:=X2;
 p^.inf.Y:=Y1;
 new(p^.n);
 p^.n^.p:=p;
 p:=p^.n;
 p^.inf.X:=X2;
 p^.inf.Y:=Y2;
 new(p^.n);
 p^.n^.p:=p;
 p:=p^.n;
 p^.inf.X:=X1;
 p^.inf.Y:=Y2;
 p^.n:=p^.p^.p^.p;
 p^.n^.p:=p;
 points:=p^.n;
end;

procedure ProcessLine;
var
 l: line;
 p,P1,P2: PPoint;
 stubP: point;
 foundct: byte;
begin
 l:=InputLine;
 CalculateLine(l);

 p:=points;
 foundct:=0;
 repeat
  if FindIntersection(l,p^.inf,p^.n^.inf,stubP) then
  begin
   AddAfter(p,stubP);
   case foundct of
    0: P1:=p;
    1: P2:=p;
   end;
   foundct:=foundct+1;
   if foundct=2 then
    break;
  end;
  p:=p^.n;
 until (p=points);
 if foundct=0 then
  exit;

 if not SameSS(l,P1^.n^.inf,T) then
 begin
  p:=P1^.n;
  while (p<>P2) do
   Remove(p);
 end
 else
 begin
  p:=P2^.n;
  while (p<>P1) do
   Remove(p);
 end;
 points:=P1;
end;

function Lng(P1,P2: point): real;
begin
 Lng:=sqrt(sqr(P1.X-P2.X)+sqr(P1.Y-P2.Y));
end;

function TriS(P1,P2,P3: point): real;
var
 a,b,c,p: real;
begin
 a:=Lng(P1,P2);
 b:=Lng(P2,P3);
 c:=Lng(P1,P3);
 p:=(a+b+c)/2;
 TriS:=sqrt(p*(p-a)*(p-b)*(p-c));
end;

function GetSurface: real;
var
 S: real;
 p: PPoint;
begin
 S:=0;
 p:=points;
 repeat
  S:=S+TriS(p^.inf,p^.n^.inf,T);
  p:=p^.n;
 until (p=points);
 GetSurface:=S;
end;

begin
 ReadRect;
 readln(T.X,T.Y);
 readln(N);
 for i:=1 to N do
  ProcessLine;
 writeln(trunc(GetSurface));
end.
