Определить есть ли в данном многоугольнике другой
type mas=array[1..1000]of real;
var x1,y1,x2,y2:mas;n1,n2,i,j:longint;s1,s2:real;
function max(a,b:real):real;
begin
if a>b then max:=a
else max:=b;
end;
function min(a,b:real):real;
begin
if a<b then min:=a
else min:=b;
end;
function p(x1,y1,x2,y2,x3,y3,x4,y4:real):boolean;
var z1,z2,z3,z4,l,w,n,r:real;
begin
z3:=(x3-x1)*(y2-y1)-(y3-y1)*(x2-x1);
z4:=(x4-x1)*(y2-y1)-(y4-y1)*(x2-x1);
z1:=(x1-x3)*(y4-y3)-(y1-y3)*(x4-x3);
z2:=(x2-x3)*(y4-y3)-(y2-y3)*(x4-x3);
if (z1*z2>0)or(z3*z4>0) then begin p:=false; exit; end;
if (z1=0)and(z2=0)and(z3=0)and(z4=0) then begin
l:=max(min(x1,x2),min(x3,x4));
r:=min(max(x1,x2),max(x3,x4));
w:=min(max(y1,y2),max(y3,y4));
n:=max(min(y1,y2),min(y3,y4));
if (l>r)or(w<n) then begin p:=false;exit; end;
end;
p:=true;
end;
function q(x,y:mas;n:longint;x0,y0:real):boolean;
var z1,z2,z3,z4,x1,y1,xmin:real;
k,i:longint;
p:boolean;
begin
for i:=1 to n do
if ( (x0-x[i])*(y[i+1]-y[i])-(y0-y[i])*(x[i+1]-x[i])=0)
and(min(x[i],x[i+1])<=x0)and(x0<=max(x[i],x[i+1]))
and(min(y[i],y[i+1])<=y0)and(y0<=max(y[i],y[i+1])) then begin p:=true; break; end;
if p=true then q:=false
else begin
xmin:=x[1];
for i:=2 to n do
xmin:=min(xmin,x[i]);
x1:=xmin-1;
y1:=y0;
if x1=x0 then x1:=x1-1;
k:=0;
for i:=1 to n do begin
z1:=(x[i]-x0)*(y1-y0)-(y[i]-y0)*(x1-x0);
z2:=(x[i+1]-x0)*(y1-y0)-(y[i+1]-y0)*(x1-x0);
z3:=(x0-x[i])*(y[i+1]-y[i])-(y0-y[i])*(x[i+1]-x[i]);
z4:=(x1-x[i])*(y[i+1]-y[i])-(y1-y[i])*(x[i+1]-x[i]);
if ((z2=0)and (z1>0)and(x[i+1]<=x0)and (x[i+1]>=x1)) or((z1=0)and(z2>0)and(x[i]<=x0)and(x[i]>=x1)) then k:=k+1
else if (z1*z2<0)and(z3*z4<0)then k:=k+1;
end;
if k mod 2=1 then q:=true else q:=false;
end;
end;
begin
readln(n1,n2);
for i:=1 to n1 do read(x1[i],y1[i]);
for i:=1 to n2 do read(x2[i],y2[i]);
x1[n1+1]:=x1[1];y1[n1+1]:=y1[1];
x2[n2+1]:=x2[1];y2[n2+1]:=y2[1];
for i:=1 to n1 do
for j:=1 to n2 do
if p(x1[i],y1[i],x1[i+1],y1[i+1],x2[j],y2[j],x2[j+1],y2[j+1]) then begin writeln('No');halt; end;
s1:=0;
for i:=1 to n1 do
s1:=s1+(y1[i]+y1[i+1])*(x1[i+1]-x1[i]);
s1:=abs(s1);
s2:=0;
for i:=1 to n2 do
s2:=s2+(y2[i]+y2[i+1])*(x2[i+1]-x2[i]);
s2:=abs(s2);
if s1>s2 then if q(x1,y1,n1,x2[1],y2[1]) then writeln('Yes') else writeln('No');
if s2>s1 then if q(x2,y2,n2,x1[1],y1[1]) then writeln('Yes') else writeln('No');
end.